Python使用turtle库绘制“李”
时间: 2023-05-23 12:05:00 浏览: 136
菊花绘制_python编程_python_turtle绘图_
5星 · 资源好评率100%
A:
```python
import turtle
# 创建画笔
pen = turtle.Pen()
# 设置画笔初始位置
pen.setposition(-100, 0)
# 绘制“李”
pen.pendown()
pen.forward(100)
pen.right(90)
pen.forward(100)
pen.left(90)
pen.forward(50)
pen.left(90)
pen.forward(50)
pen.right(180)
pen.forward(100)
pen.penup()
pen.setposition(-50, 0)
pen.pendown()
pen.forward(50)
# 隐藏画笔
pen.hideturtle()
# 等待关闭窗口
turtle.done()
```
执行上述代码,就可以看到 turtle 绘制出了一个“李”字。
阅读全文