用python画小猫简单
时间: 2023-07-12 08:29:38 浏览: 246
好的,以下是用 Python 画小猫的代码:
```python
# 导入绘图库
import turtle
# 创建画布
canvas = turtle.Screen()
# 创建画笔
pen = turtle.Turtle()
# 绘制头部
pen.circle(50)
# 绘制眼睛
pen.penup()
pen.goto(-20, 60)
pen.pendown()
pen.begin_fill()
pen.circle(10)
pen.end_fill()
pen.penup()
pen.goto(20, 60)
pen.pendown()
pen.begin_fill()
pen.circle(10)
pen.end_fill()
# 绘制鼻子
pen.penup()
pen.goto(0, 40)
pen.pendown()
pen.begin_fill()
pen.circle(5)
pen.end_fill()
# 绘制嘴巴
pen.penup()
pen.goto(-30, 0)
pen.pendown()
pen.right(45)
pen.circle(30, 90)
# 绘制身体
pen.penup()
pen.goto(-60, -50)
pen.pendown()
pen.begin_fill()
pen.forward(120)
pen.right(90)
pen.forward(100)
pen.right(90)
pen.forward(120)
pen.right(90)
pen.forward(100)
pen.end_fill()
# 绘制四肢
pen.penup()
pen.goto(-60, -50)
pen.pendown()
pen.forward(60)
pen.right(90)
pen.forward(50)
pen.right(180)
pen.forward(100)
pen.penup()
pen.goto(60, -50)
pen.pendown()
pen.forward(60)
pen.right(90)
pen.forward(50)
pen.right(180)
pen.forward(100)
# 隐藏画笔
pen.hideturtle()
# 显示画布
canvas.mainloop()
```
运行代码后,你就可以看到一个可爱的小猫啦!
阅读全文