如何遍历列表中的所有值并为每个值打印rect

时间:2018-09-27 19:16:26

标签: python list pygame

我想为所有值打印矩形,但是它只打印两个矩形,然后停止。我正在从文本文件中读取值列表,然后将该值附加到python列表中。

filepaths = glob.glob("C:/Users/Yasir Raza Khan/Desktop/Visualization 
                    GUI requirements 1-2/chipdb-5k.txt")

            data = []
 for values in filepaths:
   with open(values, "r") as f:
    for line in f.readlines():
        line = str(line.lower())
        line = line.strip().lower()
        if line.startswith('.io_tile'):
            sep = map(lambda x: tuple(map(int, x.split())), line.split(".io_tile"))
            for s in sep:
                if s != ():
                     data.append(s)
for item in data:
 x = item[0]
 y = item[1]
 pygame.draw.rect(screen, red, (x,y, 35, 25))


while True:
 for event in pygame.event.get():
    if event.type == pygame.QUIT:
        pygame.quit()
        quit()

pygame.display.update()

0 个答案:

没有答案