截取于中国大学慕课-Python语言程序设计-嵩天,仅供个人学习交流,转载注明原出处,请勿用于商业用途,侵删。
选自Python123网站,仅供个人学习交流,转载注明原出处,请勿用于商业用途,侵删。
1.蟒蛇绘制
import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.fd(-250)
turtle.pendown()
turtle.pensize(25)
turtle.pencolor("purple")
turtle.seth(-40)
for i in range(4):
turtle.circle(40,80)
turtle.circle(-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,180)
turtle.fd(40*2/3)
turtle.done()
import turtle as t
t.pensize(2)
for i in range(4):
t.fd(150)
t.left(90)
import turtle
turtle.pensize(2)
for i in range(6):
turtle.fd(100)
turtle.left(60)
turtle.done()
import turtle
turtle.pensize(2)
for i in range(10):
turtle.fd(150)
turtle.left(80)
turtle.done()
import turtle
turtle.pensize(2)
for i in range(4):
turtle.seth(90*i)
turtle.fd(150)
turtle.right(90)
turtle.circle(-150,45)
turtle.goto(0,0)
turtle.done()
import turtle
turtle.pensize(2)
for i in range(4):
turtle.seth(90*i)
turtle.fd(150)
turtle.right(90)
turtle.circle(-150,45)
turtle.fd(150)
turtle.goto(0,0)#go to也会出现轨迹痕迹,不是瞬移
turtle.done()
turtle.goto(x,y) 为从当前位置行进到(x,y)处,会产生移动轨迹,并非瞬移
turtle.seth() 对于坐标系的绝对方向
turtle.left()/turtle.right() 对于turtle所指向位置的相对方向