用python画一只草莓熊
时间: 2023-11-11 09:07:23 浏览: 118
要用Python画一只草莓熊,你可以使用turtle库来实现。以下是一个简单的示例代码:
```python
import turtle
# 设置画笔初始位置
turtle.penup()
turtle.goto(-50, 150)
turtle.pendown()
# 绘制头部
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制草莓
turtle.penup()
turtle.goto(-40, 70)
turtle.pendown()
turtle.color("red")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 绘制眼睛
turtle.penup()
turtle.goto(-70, 170)
turtle.pendown()
turtle.color("black")
turtle.begin_fill()
turtle.circle(10)
turtle.end_fill()
# 绘制嘴巴
turtle.penup()
turtle.goto(-20, 150)
turtle.pendown()
turtle.color("black")
turtle.right(60)
turtle.circle(60, 120)
# 绘制身体
turtle.penup()
turtle.goto(-100, -30)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.circle(100)
turtle.end_fill()
# 绘制四肢
turtle.penup()
turtle.goto(-140, -30)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-60, -30)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-140, -130)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
turtle.penup()
turtle.goto(-60, -130)
turtle.pendown()
turtle.color("brown")
turtle.begin_fill()
turtle.circle(20)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 完成绘制
turtle.done()
```
阅读全文