不废话,直接上代码:
import turtle
screen = turtle.Screen()
pen = turtle.Turtle()
pen.pensize(3)
pen.speed(10)
screen.bgcolor("black")
def fireworks():
for i in range(30):
pen.color("red")
pen.forward(200)
pen.left(170)
pen.penup()
pen.setpos(0, 0)
pen.pendown()
for i in range(30):
pen.color("yellow")
pen.forward(200)
pen.left(170)
pen.penup()
pen.setpos(0, 0)
pen.pendown()
for i in range(30):
pen.color("blue")
pen.forward(200)
pen.left(170)
pen.penup()
pen.setpos(0, 0)
pen.pendown()
for i in range(30):
pen.color("purple")
pen.forward(200)
pen.left(170)
pen.penup()
pen.setpos(0, 0)
pen.pendown()
for i in range(10):
fireworks()
screen.mainloop()
喜欢的关注下。