自动轨迹绘制
import turtle as t
t.title("自动轨迹绘制")
t.setup(800,600,0,0)
t.pencolor("red")
t.pensize(5)
# 读取文件
datals = []
f = open("d://data.txt")
print(f)
for line in f:
line = line.replace("\n","")
datals.append(list(map(eval,line.split(","))))
f.close()
# 自动绘制
for i in range(len(datals)):
t.pencolor(datals[i][3],datals[i][4],datals[i][5])
t.fd(datals[i][0])
if datals[i][1]:
t.right(datals[i][2])
else:
t.left(datals[i][2])
t.done()
# data.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
# 300行进距离,0转向判断(0:左转 1:右转),144转向角度,1,0,0RGB三个通道颜色
标签:文件,144,格式化,300,72,184,datals,line,数据
From: https://www.cnblogs.com/idazhi/p/17410870.html