这篇教程利用Python写一场新年烟花秀写得很实用,希望能帮到您。 我们用到的 Python 模块包括:tkinter 、PIL 、time 、random 、math ,如果第三方模块没有装的话,pip install 一下即可,下面看一下代码实现。
1.导库import tkinter as tkfrom PIL import Image, ImageTkfrom time import time, sleepfrom random import choice, uniform, randintfrom math import sin, cos, radians
2.烟花颜色colors = ['red', 'blue', 'yellow', 'white', 'green', 'orange', 'purple', 'seagreen', 'indigo', 'cornflowerblue']
3.定义烟花类 |