python新年快乐烟花
时间: 2023-12-18 22:29:53 浏览: 117
```python
import turtle
import random
# 创建画布
screen = turtle.Screen()
screen.setup(800, 600)
screen.bgcolor('black')
# 创建烟花效果
def create_firework(x, y, color):
firework = turtle.Turtle()
firework.hideturtle()
firework.speed(0)
firework.color(color)
firework.penup()
firework.goto(x, y)
firework.pendown()
firework.begin_fill()
for i in range(36):
firework.forward(100)
firework.right(170)
firework.end_fill()
# 生成烟花效果
for _ in range(30):
x = random.randint(-350, 350)
y = random.randint(-250, 250)
color = (random.random(), random.random(), random.random())
create_firework(x, y, color)
# 添加祝福语
blessing = turtle.Turtle()
blessing.hideturtle()
blessing.color('white')
blessing.penup()
blessing.goto(-200, -280)
blessing.write("祝大家2021春节愉快,祝我们的祖国繁荣昌盛!", font=("Arial", 16, "normal"))
turtle.done()
```
阅读全文