我怎样才能倒计时?

时间:2017-11-14 15:25:07

标签: python python-3.x time

所以我的代码在这里:

import time
from random import uniform
rng = uniform(1, 3)
start = time.time()
while True:
    if time.time() == start + rng:
        print("finally")

我的问题是:如何“最终”打印程序?

1 个答案:

答案 0 :(得分:0)

也加上休息;)

import time
from random import uniform
rng = uniform(1, 3)
start = time.time()
while True:
    if time.time() >= start + rng:    # first edit here (also as suggested by Patrick Haugh)
        print("finally")
        break                         # add this also to skip infinite looping