python图形绘制花朵
时间: 2023-12-06 21:38:55 浏览: 38
以下是一个绘制花朵的Python Turtle例子:
```python
import turtle as t
# 绘制花瓣
def petal():
t.begin_fill()
t.circle(50, 90)
t.left(60)
t.circle(50, 90)
t.end_fill()
# 绘制花朵
def flower():
for i in range(6):
t.color("pink", "light pink")
petal()
t.right(60)
# 绘制花心
t.color("red", "yellow")
t.up()
t.goto(0, 0)
t.down()
t.begin_fill()
t.circle(20)
t.end_fill()
# 设置画布
t.setup(800, 600)
t.bgcolor("light green")
# 绘制花朵
flower()
# 隐藏画笔
t.hideturtle()
# 点击关闭窗口
t.exitonclick()
```