代码拉取完成,页面将自动刷新
import time
def countdownTimer():
# get the number of seconds
no_of_secs = int(input('How many seconds?: '))
while no_of_secs:
if no_of_secs < 60:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = no_of_secs // 60
secs = no_of_secs % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
elif 60 <= no_of_secs < 3600:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = no_of_secs // 60
secs = no_of_secs % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
elif 3600 <= no_of_secs <= 86400:
# calculate the number of hours, minutes and seconds
hrs = no_of_secs // 3600
mins = (no_of_secs % 3600) // 60
secs = (no_of_secs % 3600) % 60
# format the hours, minutes
# and seconds to be displayed
timer = '%02d:%02d:%02d' %(hrs, mins, secs)
print(timer, end='\r')
# delay execution of code by one second
time.sleep(1)
# countdown the number of seconds
no_of_secs -= 1
print('Time Up!')
countdownTimer()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。