成都怎么成立网站,如何看网站关键词,小程序开发模板源码,asp后台怎么加载网站turtle模块是一个Python的标准库之一#xff0c;它提供了一个基于Turtle graphics的绘图库。Turtle graphics是一种流行的绘图方式#xff0c;它通过控制一个小海龟在屏幕上移动来绘制图形。
turtle模块可以让您轻松地创建和控制海龟图形#xff0c;从而帮助您学习Python编…turtle模块是一个Python的标准库之一它提供了一个基于Turtle graphics的绘图库。Turtle graphics是一种流行的绘图方式它通过控制一个小海龟在屏幕上移动来绘制图形。
turtle模块可以让您轻松地创建和控制海龟图形从而帮助您学习Python编程和图形编程的基本概念。您可以使用turtle模块绘制各种形状、线条和图案还可以通过添加颜色和其他效果来增强绘图的视觉效果。
turtle模块还提供了一些简单的函数和命令例如前进、后退、转向、设置画笔颜色和粗细等等。这些函数和命令使得您可以轻松地控制海龟的移动和绘图行为。此外turtle模块还提供了一些高级功能例如创建自己的绘图函数、保存和加载绘图文件等等。
总之turtle模块是一个非常适合初学者使用的Python库它可以帮助您学习Python编程和图形编程的基本概念并为您提供了一个轻松愉快的绘图环境。
import turtle as tdef flyTo(x, y):t.penup()t.goto(x, y)t.pendown()
def drawEye():t.tracer(False)a 2.5for i in range(120):if 0 i 30 or 60 i 90:a - 0.05else:a 0.05t.left(3)t.fd(a)t.tracer(True)
def beard(): 画胡子 一共六根# 左边第一根胡子flyTo(-37, 135)t.seth(165)t.fd(60)# 左边第二根胡子flyTo(-37, 125)t.seth(180)t.fd(60)# 左边第三根胡子flyTo(-37, 115)t.seth(193)t.fd(60)# 右边第一根胡子flyTo(37, 135)t.seth(15)t.fd(60)# 右边第二根胡子flyTo(37, 125)t.seth(0)t.fd(60)# 右边第三根胡子flyTo(37, 115)t.seth(-13)t.fd(60)
def drawRedScarf(): 画围巾t.fillcolor(red) # 填充颜色t.begin_fill()t.seth(0) # 朝向右t.fd(200) # 前进10个单位t.circle(-5, 90)t.fd(10)t.circle(-5, 90)t.fd(207)t.circle(-5, 90)t.fd(10)t.circle(-5, 90)t.end_fill()
def drawMouse():flyTo(5, 148)t.seth(270)t.fd(100)t.seth(0)t.circle(120, 50)t.seth(230)t.circle(-120, 100)
def drawRedNose():flyTo(-10, 158)t.fillcolor(red) # 填充颜色t.begin_fill()t.circle(20)t.end_fill()
def drawBlackdrawEye():t.seth(0)flyTo(-20, 195)t.fillcolor(#000000) # 填充颜色t.begin_fill()t.circle(13)t.end_fill()t.pensize(6)flyTo(20, 205)t.seth(75)t.circle(-10, 150)t.pensize(3)flyTo(-17, 200)t.seth(0)t.fillcolor(#ffffff)t.begin_fill()t.circle(5)t.end_fill()flyTo(0, 0)
def drawFace():t.forward(183) # 前行183个单位t.fillcolor(white) # 填充颜色为白色t.begin_fill() # 开始填充t.left(45) # 左转45度t.circle(120, 100) # 右边那半边脸t.seth(90) # 朝向向上drawEye() # 画右眼睛t.seth(180) # 朝向左t.penup() # 抬笔t.fd(60) # 前行60t.pendown() # 落笔t.seth(90) # 朝向上drawEye() # 画左眼睛t.penup() # 抬笔t.seth(180) # 朝向左t.fd(64) # 前进64t.pendown() # 落笔t.seth(215) # 修改朝向t.circle(120, 100) # 左边那半边脸t.end_fill() #
def drawHead(): 画了一个被切掉下半部分的圆t.penup() # 抬笔t.circle(150, 40) # 画圆, 半径150圆周角40t.pendown() # 落笔t.fillcolor(#00a0de) # 填充色t.begin_fill() # 开始填充t.circle(150, 280) # 画圆半径150, 圆周角280t.end_fill()
def drawAll():drawHead()drawRedScarf()drawFace()drawRedNose()drawMouse()beard()flyTo(0, 0)t.seth(0)t.penup()t.circle(150, 50)t.pendown()t.seth(30)t.fd(40)t.seth(70)t.circle(-30, 270)t.fillcolor(#00a0de)t.begin_fill()t.seth(230)t.fd(80)t.seth(90)t.circle(1000, 1)t.seth(-89)t.circle(-1000, 10)t.seth(180)t.fd(70)t.seth(90)t.circle(30, 180)t.seth(180)t.fd(70)t.seth(100)t.circle(-1000, 9)t.seth(-86)t.circle(1000, 2)t.seth(230)t.fd(40)t.circle(-30, 230)t.seth(45)t.fd(81)t.seth(0)t.fd(203)t.circle(5, 90)t.fd(10)t.circle(5, 90)t.fd(7)t.seth(40)t.circle(150, 10)t.seth(30)t.fd(40)t.end_fill()# 左手t.seth(70)t.fillcolor(#FFFFFF)t.begin_fill()t.circle(-30)t.end_fill()# 脚flyTo(103.74, -182.59)t.seth(0)t.fillcolor(#FFFFFF)t.begin_fill()t.fd(15)t.circle(-15, 180)t.fd(90)t.circle(-15, 180)t.fd(10)t.end_fill()flyTo(-96.26, -182.59)t.seth(180)t.fillcolor(#FFFFFF)t.begin_fill()t.fd(15)t.circle(15, 180)t.fd(90)t.circle(15, 180)t.fd(10)t.end_fill()# 右手flyTo(-133.97, -91.81)t.seth(50)t.fillcolor(#FFFFFF)t.begin_fill()t.circle(30)t.end_fill()# 口袋flyTo(-103.42, 15.09)t.seth(0)t.fd(38)t.seth(230)t.begin_fill()t.circle(90, 260)t.end_fill()flyTo(5, -40)t.seth(0)t.fd(70)t.seth(-90)t.circle(-70, 180)t.seth(0)t.fd(70)# 铃铛flyTo(-103.42, 15.09)t.fd(90)t.seth(70)t.fillcolor(#ffd200)t.begin_fill()t.circle(-20)t.end_fill()t.seth(170)t.fillcolor(#ffd200)t.begin_fill()t.circle(-2, 180)t.seth(10)t.circle(-100, 22)t.circle(-2, 180)t.seth(180 - 10)t.circle(100, 22)t.end_fill()flyTo(-13.42, 15.09)t.seth(250)t.circle(20, 110)t.seth(90)t.fd(15)t.dot(10)flyTo(0, -150)drawBlackdrawEye()
def main():t.screensize(800, 6000, #F0F0F0)t.pensize(3)t.speed(9)drawAll()
if __name__ __main__:main()t.mainloop()完毕感谢您的收看
----------★★历史博文集合★★----------
我的零基础Python教程Python入门篇 进阶篇 视频教程 Py安装py项目 Python模块 Python爬虫 Json Xpath 正则表达式 Selenium Etree CssGui程序开发 Tkinter Pyqt5 列表元组字典数据可视化 matplotlib 词云图 Pyecharts 海龟画图 Pandas Bug处理 电脑小知识office自动化办公 编程工具