今天是中秋节,学习如何用Python画出一个月亮。
参考链接:【中秋征文】使用Python中秋节程序员的浪漫《嫦娥奔月》_猿童学的博客-CSDN博客_python中秋节https://blog.csdn.net/weixin_42756970/article/details/120370077
参考链接:Python中秋赏月专用代码中秋节代码_Python代码大全的博客-CSDN博客_月亮的编程代码
准备工作
安装缺少的库
请忽略这些个warning吧。
turtle库
学习链接:python---turtle库(详解)_超越ct的博客-CSDN博客_turtle库
#绘制月亮
def drawMoon():
turtle.penup() #画笔拿起
turtle.goto(-150, 0)
turtle.fillcolor((255, 215, 0)) #圆月的颜色
turtle.pendown() #画笔放下
turtle.begin_fill()
turtle.circle(112)
turtle.end_fill() #turtle.begin_fill() 到turtle.end_fill() 颜色填充
代码
import turtle
import time
#绘制月亮
def drawMoon():
turtle.penup() #画笔拿起
turtle.goto(-150, 0)
turtle.fillcolor((255, 215, 0)) #圆月的颜色
turtle.pendown() #画笔放下
turtle.begin_fill()
turtle.circle(112)
turtle.end_fill() #turtle.begin_fill() 到turtle.end_fill() 颜色填充
#绘制云朵
def drawCloud():
turtle.penup()
turtle.goto(-500, 200)