python 蝴蝶代码
时间: 2023-07-02 07:04:25 浏览: 355
找蝴蝶代码
以下是使用 turtle 库绘制蝴蝶的 Python 代码:
```python
import turtle
# 设置画布大小和背景色
turtle.setup(500, 500)
turtle.bgcolor("pink")
# 画左翅膀
turtle.fillcolor("#FF69B4")
turtle.begin_fill()
turtle.pensize(4)
turtle.up()
turtle.goto(-100, 0)
turtle.down()
turtle.circle(50, 80)
turtle.right(140)
turtle.circle(50, 80)
turtle.end_fill()
# 画右翅膀
turtle.fillcolor("#FF69B4")
turtle.begin_fill()
turtle.up()
turtle.goto(100, 0)
turtle.down()
turtle.circle(-50, 80)
turtle.left(140)
turtle.circle(-50, 80)
turtle.end_fill()
# 画身体
turtle.up()
turtle.goto(0, 0)
turtle.down()
turtle.pensize(6)
turtle.color("#8B0000")
turtle.right(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(40)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(40)
# 结束绘制
turtle.done()
```
运行以上代码,即可在画布上绘制出一个粉色的蝴蝶。
阅读全文