使用到的库:turtle
数据:自动轨迹绘制.txt
300,0,144,1,0,0
300,0,144,0,1,0
300,0,144,0,0,1
300,0,144,1,1,0
300,0,108,0,1,1
184,0,72,1,0,1
184,0,72,0,0,0
184,0,72,0,0,0
184,0,72,0,0,0
184,1,72,1,0,1
184,1,72,0,0,0
184,1,72,0,0,0
184,1,72,0,0,0
184,1,72,0,0,0
184,1,720,0,0,0
1 #自动轨迹绘制 2 import turtle 3 turtle.title('自动轨迹绘制') 4 turtle.setup(800, 600, 0, 0) 5 turtle.pencolor('red') 6 turtle.pensize(5) 7 datals = [] 8 f = open('自动轨迹绘制.txt') 9 for line in f: 10 line = line.replace('\n','') 11 datals.append(list(map(eval, line.split(',')))) 12 f.close() 13 for i in range(len(datals)): 14 turtle.pencolor(datals[i][3],datals[i][4],datals[i][5]) 15 turtle.fd(datals[i][0]) 16 if datals[i][1]: 17 turtle.right(datals[i][2]) 18 else: 19 turtle.left(datals[i][2])
标签:turtle,0184,轨迹,自动,72,datals,绘制 From: https://www.cnblogs.com/T-2187803607/p/17142538.html