目录

哆啦A梦

捂脸表情


最近兴致来了,想把一些可爱的童年记忆的卡通形象绘制出来,你以为必须是画画才行?Python是时候让你大开眼界了,新手小伙伴们看好了~

哆啦A梦

import turtle as t# t.speed(5)t.pensize(8)t.hideturtle()t.screensize(500, 500, bg='white')# 猫脸t.fillcolor('#00A1E8')t.begin_fill()t.circle(120)t.end_fill()t.pensize(3)t.fillcolor('white')t.begin_fill()t.circle(100)t.end_fill()t.pu()t.home()t.goto(0, 134)t.pd()t.pensize(4)t.fillcolor("#EA0014")t.begin_fill()t.circle(18)t.end_fill()t.pu()t.goto(7, 155)t.pensize(2)t.color('white', 'white')t.pd()t.begin_fill()t.circle(4)t.end_fill()t.pu()t.goto(-30, 160)t.pensize(4)t.pd()t.color('black', 'white')t.begin_fill()a = 0.4for i in range(120):    if 0 <= i < 30 or 60 <= i < 90:        a = a + 0.08        t.lt(3)  # 向左转3度        t.fd(a)  # 向前走a的步长    else:        a = a - 0.08        t.lt(3)        t.fd(a)t.end_fill()t.pu()t.goto(30, 160)t.pensize(4)t.pd()t.color('black', 'white')t.begin_fill()for i in range(120):    if 0 <= i < 30 or 60 <= i < 90:        a = a + 0.08        t.lt(3)  # 向左转3度        t.fd(a)  # 向前走a的步长    else:        a = a - 0.08        t.lt(3)        t.fd(a)t.end_fill()t.pu()t.goto(-38, 190)t.pensize(8)t.pd()t.right(-30)t.forward(15)t.right(70)t.forward(15)t.pu()t.goto(15, 185)t.pensize(4)t.pd()t.color('black', 'black')t.begin_fill()t.circle(13)t.end_fill()t.pu()t.goto(13, 190)t.pensize(2)t.pd()t.color('white', 'white')t.begin_fill()t.circle(5)t.end_fill()t.pu()t.home()t.goto(0, 134)t.pensize(4)t.pencolor('black')t.pd()t.right(90)t.forward(40)t.pu()t.home()t.goto(0, 124)t.pensize(3)t.pencolor('black')t.pd()t.left(10)t.forward(80)t.pu()t.home()t.goto(0, 114)t.pensize(3)t.pencolor('black')t.pd()t.left(6)t.forward(80)t.pu()t.home()t.goto(0, 104)t.pensize(3)t.pencolor('black')t.pd()t.left(0)t.forward(80)# 左边的胡子t.pu()t.home()t.goto(0, 124)t.pensize(3)t.pencolor('black')t.pd()t.left(170)t.forward(80)t.pu()t.home()t.goto(0, 114)t.pensize(3)t.pencolor('black')t.pd()t.left(174)t.forward(80)t.pu()t.home()t.goto(0, 104)t.pensize(3)t.pencolor('black')t.pd()t.left(180)t.forward(80)t.pu()t.goto(-70, 70)t.pd()t.color('black', 'red')t.pensize(6)t.seth(-60)t.begin_fill()t.circle(80, 40)t.circle(80, 80)t.end_fill()t.pu()t.home()t.goto(-80, 70)t.pd()t.forward(160)t.pu()t.home()t.goto(-50, 50)t.pd()t.pensize(1)t.fillcolor("#eb6e1a")t.seth(40)t.begin_fill()t.circle(-40, 40)t.circle(-40, 40)t.seth(40)t.circle(-40, 40)t.circle(-40, 40)t.seth(220)t.circle(-80, 40)t.circle(-80, 40)t.end_fill()# 领带t.pu()t.goto(-70, 12)t.pensize(14)t.pencolor('red')t.pd()t.seth(-20)t.circle(200, 30)t.circle(200, 10)# 铃铛t.pu()t.goto(0, -46)t.pd()t.pensize(3)t.color("black", '#f8d102')t.begin_fill()t.circle(25)t.end_fill()t.pu()t.goto(-5, -40)t.pd()t.pensize(2)t.color("black", '#79675d')t.begin_fill()t.circle(5)t.end_fill()t.pensize(3)t.right(115)t.forward(7)t.mainloop()

捂脸表情

import turtle# 画指定的任意圆弧def arc(sa, ea, x, y, r):  # start angle,end angle,circle center,radius    turtle.penup()    turtle.goto(x, y)    turtle.setheading(0)    turtle.left(sa)    turtle.fd(r)    turtle.pendown()    turtle.left(90)    turtle.circle(r, (ea - sa))    return turtle.position()turtle.hideturtle()# 画脸turtle.speed(5)turtle.setup(900, 600, 200, 200)turtle.pensize(5)turtle.right(90)turtle.penup()turtle.fd(100)turtle.left(90)turtle.pendown()turtle.begin_fill()turtle.pencolor("#B26A0F")  # head side colorturtle.circle(150)turtle.fillcolor("#F9E549")  # face colorturtle.end_fill()# 画嘴turtle.penup()turtle.goto(77, 20)turtle.pencolor("#744702")turtle.goto(0, 50)turtle.right(30)turtle.fd(110)turtle.right(90)turtle.pendown()turtle.begin_fill()turtle.fillcolor("#925902")  # mouth colorturtle.circle(-97, 160)turtle.goto(92, -3)turtle.end_fill()turtle.penup()turtle.goto(77, -25)# 画牙齿turtle.pencolor("white")turtle.begin_fill()turtle.fillcolor("white")turtle.goto(77, -24)turtle.goto(-81, 29)turtle.goto(-70, 43)turtle.goto(77, -8)turtle.end_fill()turtle.penup()turtle.goto(0, -100)turtle.setheading(0)turtle.pendown()# 画左边眼泪turtle.left(90)turtle.penup()turtle.fd(150)turtle.right(60)turtle.fd(-150)turtle.pendown()turtle.left(20)turtle.pencolor("#155F84")  # tear side colorturtle.fd(150)turtle.right(180)position1 = turtle.position()turtle.begin_fill()turtle.fillcolor("#7EB0C8")  # tear colorturtle.fd(150)turtle.right(20)turtle.left(270)turtle.circle(-150, 18)turtle.right(52)turtle.fd(110)position2 = turtle.position()turtle.goto(-33, 90)turtle.end_fill()# 画右边眼泪turtle.penup()turtle.goto(0, 0)turtle.setheading(0)turtle.left(90)turtle.fd(50)turtle.right(150)turtle.fd(150)turtle.left(150)turtle.fd(100)turtle.pendown()turtle.begin_fill()turtle.fd(-100)turtle.fillcolor("#7EB0C8")  # tear colorturtle.right(60)turtle.circle(150, 15)turtle.left(45)turtle.fd(66)turtle.goto(77, 20)turtle.end_fill()# 画眼睛turtle.penup()turtle.pencolor("#6C4E00")  # eye colorturtle.goto(-65, 75)turtle.setheading(0)turtle.left(27)turtle.fd(38)turtle.pendown()turtle.begin_fill()turtle.fillcolor("#6C4E00")  # eye colorturtle.left(90)turtle.circle(38, 86)turtle.goto(position2[0], position2[1])turtle.goto(position1[0], position1[1])turtle.end_fill()# 画手turtle.pencolor("#D57E18")  # hand side colorturtle.begin_fill()turtle.fillcolor("#EFBD3D")  # hand color# 第一个手指arc(-110, 10, 110, -40, 30)turtle.circle(300, 35)turtle.circle(13, 120)turtle.setheading(-50)turtle.fd(20)turtle.setheading(130)# 第二个手指turtle.circle(200, 15)turtle.circle(12, 180)turtle.fd(40)turtle.setheading(137)# 第三个手指turtle.circle(200, 16)turtle.circle(12, 160)turtle.setheading(-35)turtle.fd(45)turtle.setheading(140)# 第四个手指turtle.circle(200, 13)turtle.circle(11, 160)turtle.setheading(-35)turtle.fd(40)turtle.setheading(145)# 第五个手指turtle.circle(200, 9)turtle.circle(10, 180)turtle.setheading(-31)turtle.fd(50)# 画最后手腕的部分turtle.setheading(-45)turtle.pensize(7)turtle.right(5)turtle.circle(180, 35)turtle.end_fill()turtle.begin_fill()turtle.setheading(-77)turtle.pensize(5)turtle.fd(50)turtle.left(-270)turtle.fd(7)turtle.pencolor("#EFBD3D")turtle.circle(30, 180)turtle.end_fill()# 测试# res=arc(70,220,90,50,300)# print(res[0],res[1])turtle.done()

怎么样好玩吧?Python的小例子还有很多,如果你也是Python爱好者,我这里也整理了一套完整的新手学习路线跟资料,戳下面名片找小助理领取

初级选手表示太好玩了 | python turtle绘图集锦(哆啦A梦、捂脸表情)相关推荐

  1. python画图哆啦a梦-Python—turtle画图(哆啦A梦)

    [知识延伸] 在Python中有一个名为turtle的工具,也可以称他为画图工具,这是一种Python所独有的工具.是他为我们所包装好的模块,在这里 [要求] 今天我们利用turtle画图来绘制一个哆 ...

  2. Python Turtle绘图[难度2星]:甜美棒棒糖(基础效果 / 加描边优化)

    我喜欢turtle绘图,因为代码一点点的改动,总会带来意想不到的惊喜. 一些让我心动过的案例,分享给大家,也珍藏给自己. --Python教学路上的爬行者    案例1:棒棒糖(基础效果)       ...

  3. pythonturtle简单绘图_10分钟轻松学会 Python turtle 绘图

    10分钟轻松学会 Python turtle 绘图 python2.6版本中后引入的一个简单的绘图工具,叫做海龟绘图(Turtle Graphics),turtle库是python的内部库,使用导入即 ...

  4. 巴斯光年python turtle绘图__附源代码

    巴斯光年python turtle绘图__附源代码 本文目录: 一.python turtle海龟绘图效果图 写在前面的题外话 二.绘图人物简介 三.代码演示方法和代码命令解释 四.怎么才能正常运行p ...

  5. 十分钟轻松学会python-10分钟轻松学会python turtle绘图

    python2.6版本中后引入的一个简单的绘图工具,叫做海龟绘图(Turtle Graphics),turtle库是python的内部库,使用导入即可 import turtle 先说明一下turtl ...

  6. python turtle循环图案-有趣的Python turtle绘图

    原标题:有趣的Python turtle绘图 Python Turtle是Python的一个编程教育类库,越来越受到教育者的关注,近日,以"智能时代,逐梦成长"为主题的第5届全国青 ...

  7. python turtle 绘图速度用函数会快吗_有趣的Python turtle绘图

    专 题 Feature Story 16 \ China Science & Technology Education 文 _ 毛京宇/北京师范大学第三附属中学 魏云靖/北京市师达中学 有趣的 ...

  8. python画图哆啦a梦大作业_Python—turtle画图(哆啦A梦)

    [知识延伸] 在Python中有一个名为turtle的工具,也可以称他为画图工具,这是一种Python所独有的工具.是他为我们所包装好的模块,在这里 [要求] 今天我们利用turtle画图来绘制一个哆 ...

  9. Python Turtle绘图[难度3星]:24节气倒计时(2.使用字典存储数据)

    "我喜欢turtle绘图,因为代码一点点的改动,总会带来意想不到的惊喜. 一些让我心动过的案例,分享给大家,也珍藏给自己." -- 初中信息技术教师  许华丽 Python Tur ...

最新文章

  1. Linux系统下统计目录及其子目录文件个数
  2. 浅谈javascript中的数据类型和引用类型
  3. java中class_JAVA中的Class类
  4. VisualVM——JDK自带的性能分析工具
  5. case study
  6. Flask实战第41天:发送短信验证码
  7. 1.关于python
  8. TensorFlow 深度学习中文第二版·翻译完成
  9. sql server分页_SQL Server中的分页
  10. IDEA 配置 SpringBoot 启动端口
  11. Visual Studio Code 基本操作 - Windows 版
  12. 后缀数组算法概述及习题
  13. 批量导入经纬度点到奥维地图中
  14. 戴尔计算机网卡驱动程序,dell戴尔网卡驱动如何安装
  15. 转载-【常用RGB颜色查询对照表及感情色】
  16. 判断对错html,js制作单选题,能判断对错
  17. 使用get传参的时候,参数在后头获取不到或者出现别的错误。
  18. 阿里云服务器最新价格表(标准收费报价表)
  19. Belief Propagation信念传播算法详解
  20. 图形B=B≌B凸显中学数学有一系列重大错误(更新稿) ——合同图形概念让5000年无人能识的自然数一下子浮出水面

热门文章

  1. 让我一机灵的Java语言知识点
  2. 详解SAX解析XML
  3. cortana 无法使用_如何在Windows 10上使用Cortana控制您的智能家居产品
  4. C#无法加载DLL‘‘‘###.dll‘,找不到指定的模块。(异常来自HRESULT:0x8007007E)
  5. python 小兵(3)字典
  6. 电脑磁盘内的PPT文档不见了,如何尽快找回?
  7. 第一次运行TestNG测试类时报Cannot find class in classpath
  8. C++解题报告:病毒(virus)——拓扑排序
  9. 【猜丁壳】小游戏练习
  10. 无处 不在的无线智能——6g 的关键驱动与研究挑战_三星电子发布6G白皮书 网友:先把5G弄明白...