本文主要是介绍python 学习 自动轨迹绘制 DAY10,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import turtledef getTxt():
while True:
name = input("请输入打开文件名字:")
if name !=" ":
break
txt = open(name,"r")
datals = []
for line in txt:
line = line.replace('\n',' ')
datals.append(list(map(eval,line.split(","))))
txt.close()
return datals
def initia():
turtle.title("自动轨迹绘制")
turtle.setup(800,600,200,200)
turtle.pencolor("red")
turtle.pensize(5)
turtle.speed(10)
def deal(datals):
for i in range(len(datals)):
turtle.pencolor(datals[i][3],datals[i][4],datals[i][5])
turtle.fd(datals[i][0])
if datals[i][1]:
turtle.right(datals[i][2])
else:
turtle.left(datals[i][2])
turtle.hideturtle()
if __name__=="__main__":
n = getTxt()
initia()
deal(n)
这篇关于python 学习 自动轨迹绘制 DAY10的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!