反转算法演示程序.py

0 Comments

李兴球Python反转算法演示程序

李兴球Python反转算法演示程序

"""
   反转算法演示程序.py
"""
from sprites import *
from random import randint

screen = Screen()
screen.delay(10)

w = Sprite('blank')
w.color('gray84')
w.sety(50)
w.write('反转算法演示程序',align='center',font=('黑体',34))

digits = [randint(0,1000) for _ in range(randint(5,10))]
names = [f'res/_{d}.png' for d in digits]
[txt2image(str(d),filename,fontsize=22 ) for d,filename in zip(digits,names)]
n = len(digits)                    # 角色数量 
x = -(n-1)*70/2                    # 最左边角色的x坐标
numbers = []
for i in range(n):
    p = Sprite(names[i],pos=(x,220))
    p.stamp()
    p.speed(1)
    numbers.append(p)
    x = x + 70
[p.sety(0) for p in numbers]

i = 0
j = n-1
while i
                    标签:                

发表评论