用python的turtle画吃豆人
时间: 2023-05-24 10:01:11 浏览: 107
可以使用以下代码在Python的turtle模块中画出吃豆人:
```python
import turtle
# 设置画布大小及背景颜色
turtle.setup(width=600, height=600)
turtle.bgcolor('black')
# 画出吃豆人形状
turtle.pensize(3)
turtle.penup()
turtle.goto(-200, 0)
turtle.pendown()
turtle.color('yellow')
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
turtle.penup()
turtle.goto(-180, 60)
turtle.pendown()
turtle.color('black')
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-180, 15)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-180, -30)
turtle.pendown()
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
turtle.penup()
turtle.goto(-170, 70)
turtle.pendown()
turtle.color('white')
turtle.begin_fill()
turtle.circle(5)
turtle.end_fill()
# 关闭turtle窗口
turtle.done()
```
阅读全文