1
发表在达人风采
2020-05-23
是否精华
是
否
版块置顶:
是
否
import time
print('按下回车开始计时,按下 Ctrl + C 停止计时。')
while True:
input("")
start = time.time()
print('计时开始')
try:
while True:
x=time.time()-start
ms=int(x%1*1000)
s=int(x%60)
m=int(x//60%60)
h=int(x//60//60)
print('{:0>2d}:{:0>2d}:{:0>2d}:{:0>3d}'.format(h,m,s,ms),end='\r')
time.sleep(0.001)
except KeyboardInterrupt:
break
print('{:0>2d}:{:0>2d}:{:0>2d}:{:0>3d}'.format(h,m,s,ms))
print('计时结束')