我有一个运行 16 次的循环,因为它读取的文件中有 16 行,我正在使用一个循环来读取时间戳的前两个字符。但我不知道如何防止 n 变量达到 17。我尝试使用 while 条件将 n 限制为 16,但无济于事。这是我的全部功能,我正在尝试为飓风艾琳的路径制作动画,详见http://calicoproject.org/Calico_Python_GIS:
def drawIrene(win):
line = Line()
n = 0
for (x,y) in dots:
time_stamp[n] = time_stamp[n][:2]
time_stamp[n+1] = time_stamp[n+1][:2]
time1 = abs(int(time_stamp[n]) - 12)
time2 = abs(int(time_stamp[n+1]) - 12)
wait_time = abs(int(time1) - int(time2))
x, y = ll2xy(x, y)
c = Circle(Point(x, y), int(eye_size[n]))
line.append(Point(x,y))
c.fill = Color(255, 255, 0, 62)
c.draw(win)
t = Polygon((x, y), (x+10, y+5), (x+int(movement_speed[n]), y-int(movement_speed[n])/2))
t.fill = Color("orange")
t.draw(win)
print(time1)
print(time2)
print()
#print (wait_time)
wait(wait_time)
if n < len(dots):
n += 1
else:
break
line.draw(win)
line.border = 2