python中设定时间的数字倒计时
我需要创建一个程序,从设定的时间开始进行数字倒计时。它需要打印出来,所以它的读数是小时:分钟:秒python中设定时间的数字倒计时,python,time,Python,Time,我需要创建一个程序,从设定的时间开始进行数字倒计时。它需要打印出来,所以它的读数是小时:分钟:秒 import time count=int(input("Enter your start point")) count2=int(input("Enter your start point")) count3=int(input("Enter your start point")) while count and count and count3 >0: time.slee
import time
count=int(input("Enter your start point"))
count2=int(input("Enter your start point"))
count3=int(input("Enter your start point"))
while count and count and count3 >0:
time.sleep(1)
print(count,+":",+":",+count3)
count -=1
count2 -=1
count3 -=1
试试这个。如果需要,可以在数字中添加填充。这是POC
>>1:0:4
>>1:0:3
>>1:0:2
>>1:0:1
>>1:0:0
>>0:59:59
>>0:59:58
>>0:59:57
>>0:59:56
我修改了您的代码,这将生成您所需的输出。
如有任何疑问,请告知我,
import time
count=int(input("Enter your start point"))
count2=int(input("Enter your start point"))
count3=int(input("Enter your start point"))
while count | count2 | count3 >0:
while(count>=0):
while(count2>=0):
while(count3>=0):
time.sleep(1)
print count,":",count2,":",+count3
count3 -= 1
count3 = 59
count2 -= 1
count2 = 59
count -= 1
在旧代码中使用了AND运算符,因此即使任何变量为零,它也会终止执行。输出:
1 : 0 : 4
1 : 0 : 3
1 : 0 : 2
1 : 0 : 1
1 : 0 : 0
0 : 59 : 59
0 : 59 : 58
0 : 59 : 57
0 : 59 : 56
0 : 59 : 55
0 : 59 : 54
0 : 59 : 53
0 : 59 : 52
请分享您的尝试…导入时间计数=int(输入(“输入您的起点”))计数2=int(输入(“输入您的起点”))计数3=int(输入(“输入您的起点”)),同时计数和计数,计数3>0:time。睡眠(1)打印(计数,+“:”,+“:”,+count3)count-=1 count2-=1 count3-=1请用您尝试的代码更新您的问题。这样你就不会受到厌恶。
1 : 0 : 4
1 : 0 : 3
1 : 0 : 2
1 : 0 : 1
1 : 0 : 0
0 : 59 : 59
0 : 59 : 58
0 : 59 : 57
0 : 59 : 56
0 : 59 : 55
0 : 59 : 54
0 : 59 : 53
0 : 59 : 52