Python语言中文件操作实例(1)--Python(20)

来源:互联网 发布:蓝色星球软件 编辑:程序博客网 时间:2024/06/09 04:25

这里写图片描述

这里写图片描述

#the window setimport turtleturtle.title('数据驱动的动态路径绘制')turtle.setup(1200,600,0,0)#设置画笔pen = turtle.Turtle()pen.color("red")pen.width(5)pen.shape("turtle")pen.speed(5)#read the file to the list resultresult=[]file=open("data.txt","r")for line in file:    result.append(list(map(float,line.split(','))))print (result)#根据每一条数据记录进行绘制for i in range(len(result)):    pen.color((result[i][3],result[i][4],result[i][5]))    pen.fd(result[i][0])    if result[i][1]:        pen.rt(result[i][2])    else:        pen.lt(result[i][2])