使用zip方法将列表组合到一个点列表中
例
import pygame
pygame.init()
screen = pygame.display.set_mode((300, 300))
x = (0, 100, 200, 300)
y = (300, 100, 20, 50)
points = zip(x, y)
last = None
for p in points:
if last:
pygame.draw.line(screen, (255,255,0), last, p)
print last, p
last = p
pygame.display.flip()
Run Code Online (Sandbox Code Playgroud)
结果:
(0,300)(100,100)
(100,100)(200,20)
(200,20)(300,50)
