Python画哆啦A梦,祝大家儿童节快乐
演示效果:
完整Python代码:
import turtle as t
def getXYList(fpath):
# 该函数获取txt文件中的坐标列表
outXYList = []
with open(fpath) as f:
lines = f.readlines()
for line in lines:
# print(tuple(line.replace('\n','').split(',')))
pos = tuple([int(x) for x in line.replace('\n','').split(',')])
outXYList.append(pos)
return outXYList
def drawFigure(posList=[],color='white'):
# 该函数遍历坐标列表,绘制图形,并填充颜色
t.fillcolor(color