关于turtle库的自动轨迹规划问题
data = 300,0,144,1,0,0300,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
import turtle as t
t.setup(800, 600, 0, 0)
t.pencolor('green')
t.pensize(5)
t.title('自动轨迹绘制')
datals = []
f = open('data.txt')
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,datals,datals)
t.fd(datals)
if datals:
t.right(datals)
else:
t.left(datals)
想问一下各位大佬这行代码:line = line.replace('\n', ''),把换行符替换掉,那就是原来的txt文本每行都自带换行符吗????
页:
[1]