import turtle as t t.title(‘自动绘制轨迹‘) t.setup(800,600,0,0) t.pencolor("red") t.pensize(5) def tprint(a): t.pencolor(a[3],a[4],a[5]) t.fd(a[0]) if a[1]: t.right(a[2]) else: t.left(a[2]) f = open("t.txt") data= list() for line in f: if len(line) == 1: break; data = line.replace("\n","") #去掉每一行的换行 #print(data) data = eval(data) #转换为元组 #print(data) #print(data[0]) tprint(data) #元组传参 f.close()
#以下为t.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
原文:https://www.cnblogs.com/hardfood/p/14177278.html