python - 如何倒计时让计时器用户输入内容
问题描述
当用户输入他们的年龄时,我需要倒计时来倒计时
# 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))
解决方案
推荐阅读
- gradle-kotlin-dsl - 找不到名称为“jvmMain”的 SourceSet
- git - 每个遥控器禁用或正确安装 git LFS
- string - 仅在不是空字符串时打印
- r - grid.arrange 两个具有相同 y 轴刻度的图
- javascript - 如何模拟慢速互联网连接以测试网页?
- python - 如何使用按钮在 django 服务器中运行 python 脚本
- ionic-framework - 如何在离子中默认禁用白色闪屏?
- xamarin.forms - 为 iOS Xamarin 表单执行远程构建时出现 Prism Navigation 错误
- c - 为什么 UTF-8 输出到 C 控制台可以与 Cygwin 一起使用,但不能与 MinGW 一起使用?
- javascript - Angular - 在项目中保留变量的最佳方法