turtle的setup.py是由python2所写,python3通过pip install turtle会报错
解决方法请参考: https://blog.csdn.net/L_15156024189/article/details/86551245
亲测可行
参考:https://docs.python.org/3/library/turtle.html
考虑到penup(),goto(),pendown()等函数的频繁组合使用,因此选择封装成run()和change()函数。
import turtle
def run(angle, lenth):
turtle.seth(angle)
turtle.fd(lenth)
def change(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.setup(800, 400, 200, 200)
turtle.pensize(10)
turtle.pencolor("red")
change(-350, 100)
run(0, 300)
change(-250, 120)
run(-90, 40)
change(-150, 120)
run(-90, 40)
change(-250, 70)
run(-135, 100)
change(-250, 70)
run(0, 60)
run(-135, 120)
change(-250, 60)
run(-45, 49)
change(-150, 70)
run(-45, 100)
change(-150, 70)
run(0, 60)
run(-135, 60)
change(-220, 20)
run(0, 40)
change(-240, 0)
run(0, 80)
change(-200, 0)
run(-90, 80)
change(-240, -40)
run(-135, 40)
change(-160, -40)
run(-45, 40)
change(50, 120)
run(-135, 100)
change(40, 100)
run(0, 50)
change(40, 60)
run(0, 50)
change(30, 20)
run(0, 80)
change(75, 60)
run(-90, 120)
change(200, 100)
run(-135, 100)
change(200, 100)
run(0, 50)
run(-135, 150)
change(175, 70)
run(-45, 40)
change(175, 0)
run(0, 60)
run(-90, 60)
run(-180, 60)
run(90, 60)