用python的turtle写晴字
时间: 2023-07-01 07:28:31 浏览: 84
Python使用turtle库绘制小猪佩奇(实例代码)
5星 · 资源好评率100%
好的,以下是用Python的turtle模块画晴字的代码:
```python
import turtle
# 设置画布大小
turtle.setup(800, 800)
# 创建画笔
pen = turtle.Turtle()
# 设置画笔大小和颜色
pen.pensize(5)
pen.color('black')
# 画晴字的笔画
pen.penup()
pen.goto(-100, 100)
pen.pendown()
pen.right(90)
pen.forward(200)
pen.right(90)
pen.forward(80)
pen.left(90)
pen.forward(80)
pen.right(90)
pen.forward(80)
pen.right(90)
pen.forward(80)
pen.left(90)
pen.forward(80)
pen.right(90)
pen.forward(80)
pen.right(90)
pen.forward(80)
# 隐藏画笔
pen.hideturtle()
# 点击关闭窗口
turtle.exitonclick()
```
运行代码后,会弹出一个窗口,里面画出了一个“晴”字。
阅读全文