python用turtle写汉字李恩航
时间: 2023-08-22 14:05:49 浏览: 108
使用Python的turtle写字
好的,以下是Python的代码:
```python
import turtle
# 创建画笔
pen = turtle.Turtle()
# 设置画笔宽度和颜色
pen.width(5)
pen.color("blue")
# 画出字母“李”
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
# 移动画笔位置
pen.penup()
pen.goto(100, 0)
pen.pendown()
# 画出字母“恩”
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
# 移动画笔位置
pen.penup()
pen.goto(200, 0)
pen.pendown()
# 画出字母“航”
pen.left(90)
pen.forward(100)
pen.right(90)
pen.forward(50)
pen.right(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.right(90)
pen.forward(100)
# 隐藏画笔
pen.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
运行上述代码后,你就可以看到用turtle库成功画出了“李恩航”的汉字。
阅读全文