python用turtle写名字李恩航
时间: 2023-07-01 10:28:15 浏览: 154
好的,以下是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(80, 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(160, 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库成功画出了“李恩航”的名字。
阅读全文