Pythonturtle库能画出什么好玩的东西

更新时间:02-01 教程 由 花栀 分享

能画出表白爱心

以下代码:

先导入turtle库

importturtle
importmath
#画出完整的爱心
t=turtle.pen()
t=turtle
t.up()
t.goto(0,150)
t.down()
t.color('red')
t.begin_fill()
t.fillcolor('red')
t.speed(1)
t.left(45)
t.forward(150)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(250+math.sqrt(2)*100)
t.right(90)
t.speed(2)
t.forward(250+100*math.sqrt(2))
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(100)
t.right(45)
t.forward(150)
t.end_fill()
t.goto(-10,0)
t.pencolor('white')


#再画出L
t.pensize(10)
t.goto(-50,0)
t.goto(-50,80)
t.up()


#再画出I
t.goto(-100,0)
t.down()
t.goto(-160,0)
t.goto(-130,0)
t.goto(-130,80)
t.goto(-160,80)
t.goto(-100,80)
t.up()


#再画出O,V,E
t.goto(10,25)
t.down()
t.right(45)
t.circle(25,extent=180)
t.goto(60,55)
t.circle(25,extent=180)
t.goto(10,25)
t.up()
t.goto(75,80)
t.down()
t.goto(100,0)
t.goto(125,80)
t.up()
t.goto(180,80)
t.down()
t.goto(140,80)
t.goto(140,0)
t.goto(180,0)
t.up()
t.goto(180,40)
t.down()
t.goto(140,40)


#再画出U
t.up()
t.goto(-40,-30)
t.down()
t.goto(-40,-80)
t.circle(40,extent=180)
t.goto(40,-30)
t.hideturtle()

{!--PGC_VIDEO:{"thumb_height":359,"vid":"v020160d0000bv5iivkpdtanncgqufv0","thumb_width":640,"vposter":"https://p3-sign.toutiaoimg.com/tos-cn-i-0022/8fe102053a784947a39b16b1aa3178ec~noop.image?x-expires=1993137613&x-signature=UEU8II88GAMdHcFgsbeZWqW%2B7Yw%3D","vu":"v020160d0000bv5iivkpdtanncgqufv0","duration":30.999,"thumb_url":"tos-cn-i-0022/8fe102053a784947a39b16b1aa3178ec","thumb_uri":"tos-cn-i-0022/8fe102053a784947a39b16b1aa3178ec","video_size":{"high":{"duration":30.999,"h":359,"w":640},"ultra":{"duration":30.999,"h":359,"w":640},"normal":{"duration":30.999,"h":359,"w":640}}}--}

声明:关于《Pythonturtle库能画出什么好玩的东西》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2162021.html