【发布时间】:2020-05-06 01:45:49
【问题描述】:
我有 3 个变量(ADG、DR、TC),我想分别计算每个 45 分钟和 2.5 小时通过的每个 3 个变量。我有这段代码来创建一个 24 小时计时器,我需要将这些变量(及其计数)添加到 while when_to_stop > 0: 循环中。有什么建议吗?谢谢!
import time
while True:
uin = input(">>")
try:
when_to_stop = abs(int(uin))
except KeyboardInterrupt:
break
except:
print("Not a number!")
while when_to_stop > 0:
m, s = divmod(when_to_stop, 60)
h, m = divmod(m, 60)
time_left = str(h).zfill(2) + ":" + str(m).zfill(2) + ":" + str(s).zfill(2)
print(time_left + "\r", end="" )
time.sleep(0.001)
when_to_stop -= 1
# ADG - Auto Droplet Generator (45 mins)
# DR - Droplet Reader (time same as TC)
# TC - Ther mal cycler (2.5 hrs)
"""
【问题讨论】:
标签: time while-loop count counter