首页 > 解决方案 > 如何倒计时让计时器用户输入内容

问题描述

当用户输入他们的年龄时,我需要倒计时来倒计时

# import the time module
import time

# define the countdown func.
def countdown(t):
    
    while t:
        mins, secs = divmod(t, 60)
        timer = '{:02d}:{:02d}'.format(mins, secs)
        print(timer, end="\r")
        time.sleep(1)
        t -= 1
    
    print('Fire in the hole!!')


# input time in seconds
t = 10

# function call
countdown(int(t))

标签: pythonpython-3.x

解决方案


推荐阅读