python飘扬的五星红旗代码
时间: 2023-11-12 09:57:42 浏览: 148
以下是Python飘扬的五星红旗代码:
```
import turtle
# 设置画布大小
turtle.setup(800, 600)
# 设置画笔颜色和大小
turtle.pensize(5)
turtle.pencolor('red')
# 画五角星
def draw_star(x, y, size):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
for i in range(5):
turtle.forward(size)
turtle.right(144)
turtle.forward(size)
turtle.left(72)
turtle.end_fill()
# 画大五角星
draw_star(-200, 100, 200)
# 画四个小五角星
stars = [(-100, 170), (-50, 200), (-50, 120), (-100, 90)]
for star in stars:
draw_star(star[0], star[1], 50)
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
```
阅读全文