用python画五星红旗
时间: 2023-10-10 08:15:39 浏览: 61
```python
import turtle
# 设置画布大小
turtle.setup(600, 400)
# 绘制红色背景
turtle.penup()
turtle.goto(-250, 150)
turtle.pendown()
turtle.color('red')
turtle.begin_fill()
for i in range(2):
turtle.forward(500)
turtle.right(90)
turtle.forward(300)
turtle.right(90)
turtle.end_fill()
# 绘制大五角星
turtle.penup()
turtle.goto(-200, 100)
turtle.pendown()
turtle.color('yellow')
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
# 绘制四个小五角星
positions = [(-120, 120), (-120, 60), (-60, 90), (-60, 30)]
for position in positions:
turtle.penup()
turtle.goto(position)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(30)
turtle.right(144)
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 显示绘制结果
turtle.done()
```
运行结果如下:
![五星红旗](https://cdn.luogu.com.cn/upload/image_hosting/cjz9v9ve.png)
阅读全文