流星雨python代码
时间: 2023-11-09 12:01:07 浏览: 107
Python流星雨代码[自写全代码]
5星 · 资源好评率100%
以下是Python实现流星雨的代码:
```python
import turtle as tu
import random as ra
import math
tu.setup(1.0, 1.0)
tu.screensize(1.0, 1.0)
tu.bgcolor('black')
t = tu.Pen()
t.ht()
colors = ['red', 'yellow', 'white', 'purple', 'blue']
while True:
x = ra.randint(-500, 500)
y = ra.randint(200, 800)
t.pu()
t.goto(x, y)
t.pd()
t.pencolor(ra.choice(colors))
size = ra.randint(10, 40)
for i in range(size):
t.fd(i)
t.rt(144.0 - 360.0 / (2 * size))
t.undo()
```
阅读全文