我试图制作一个计时器,将打印的东西,当一个变量达到2502,但不是在一定的时间做它只是打印是一次,我不知道如何解决它。
n1 = str(",..")
n2 = str(".,.")
n3 = str("..,")
print(n1)
timer = 2
while timer < 2502:
timer += 1
if timer == int("2502"):
print(n2)
timer2 = 2
while timer2 < 2502:
timer2 += 1
if timer2 == int("2502"):
print(n3)
可以在while循环中插入时间滞后。(我减少了一点检查程序的时间)
import time # import the module
n1 = str(",..")
n2 = str(".,.")
n3 = str("..,")
print(n1)
timer = 2
while timer < 10:
time.sleep(1) # will do nothing for one second
timer += 1
if timer == int("10"):
print(n2)
timer2 = 2
while timer2 < 10:
time.sleep(1) # will do nothing for one second
timer2 += 1
if timer2 == int("10"):
print(n3)