鱼C论坛

 找回密码
 立即注册
查看: 3928|回复: 11

[学习笔记] 用python画国旗

[复制链接]
发表于 2020-3-10 10:05:13 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. import turtle

  2. turtle.bgcolor("red")
  3. turtle.fillcolor("yellow")
  4. turtle.color('yellow')
  5. turtle.speed(10)
  6. #主星
  7. turtle.begin_fill()
  8. turtle.up()
  9. turtle.goto(-600,220)
  10. turtle.down()
  11. for i in range (5):   
  12.     turtle.forward(150)
  13.     turtle.right(144)
  14. turtle.end_fill()

  15. #第1颗副星
  16. turtle.begin_fill()
  17. turtle.up()
  18. turtle.goto(-400,295)
  19. turtle.setheading(305)
  20. turtle.down()
  21. for i in range (5):   
  22.     turtle.forward(50)
  23.     turtle.left(144)

  24. turtle.end_fill()


  25. #第2颗副星
  26. turtle.begin_fill()
  27. turtle.up()
  28. turtle.goto(-350,212)
  29. turtle.setheading(30)
  30. turtle.down()
  31. for i in range (5):  
  32.     turtle.forward(50)
  33.     turtle.right(144)

  34. turtle.end_fill()

  35. #第3颗副星
  36. turtle.begin_fill()
  37. turtle.up()
  38. turtle.goto(-350,145)
  39. turtle.setheading(5)
  40. turtle.down()
  41. for i in range (5):   
  42.     turtle.forward(50)
  43.     turtle.right(144)

  44. turtle.end_fill()

  45. #第4颗副星
  46. turtle.begin_fill()
  47. turtle.up()
  48. turtle.goto(-400,90)
  49. turtle.setheading(300)
  50. turtle.down()
  51. for i in range (5):  
  52.     turtle.forward(50)
  53.     turtle.left(144)

  54. turtle.end_fill()
  55. input()

复制代码

本帖被以下淘专辑推荐:

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2020-3-10 16:53:16 | 显示全部楼层
我试了3次你的代码,发现主星有一半没出来且画完后程序无响应
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-10 19:43:14 | 显示全部楼层
复制代码并运行,发现无主星,副星位置不对,且无响应(关不掉)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 0 反对 1

使用道具 举报

发表于 2020-3-11 10:26:01 | 显示全部楼层
试了下,报错,TclError: no display name and no $DISPLAY environment variable
用colab运行的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-18 20:22:56 | 显示全部楼层
andtom 发表于 2020-3-10 19:43
复制代码并运行,发现无主星,副星位置不对,且无响应(关不掉)

开全屏就能看到主星了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-18 20:23:27 | 显示全部楼层
墨羽岚 发表于 2020-3-10 16:53
我试了3次你的代码,发现主星有一半没出来且画完后程序无响应

我的不会啊
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-18 20:24:01 | 显示全部楼层
DavidCT 发表于 2020-3-11 10:26
试了下,报错,TclError: no display name and no $DISPLAY environment variable
用colab运行的

用IDLE的new  file运行就好了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-18 20:37:59 | 显示全部楼层
墨羽岚 发表于 2020-3-10 16:53
我试了3次你的代码,发现主星有一半没出来且画完后程序无响应

画完后要手动关掉(我设置的,不喜欢可以自己改过来)
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-3-18 20:45:30 | 显示全部楼层
乘号 发表于 2020-3-18 20:37
画完后要手动关掉(我设置的,不喜欢可以自己改过来)

啊啊,对不起,我当时运行的时候没开全屏
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-3-18 20:47:25 | 显示全部楼层
墨羽岚 发表于 2020-3-18 20:45
啊啊,对不起,我当时运行的时候没开全屏

没事,正常
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-10-26 12:44:52 | 显示全部楼层
其实可以用函数封装得更好看
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-1-14 08:28:33 | 显示全部楼层
墨羽岚 发表于 2020-3-10 16:53
我试了3次你的代码,发现主星有一半没出来且画完后程序无响应

我和你一样
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-4-26 17:01

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表