说明
按Enter开始,按Ctrl+C停止
[注意:请勿在编辑器中执行本程序]
代码
from time import time as ti
from os import system
def t():
return(float('%.2f' % ti()))
start_time=0 #开始时时间戳
time=[0,0,0] #时间差 [时,分,秒]
input('按Enter开始...')
start_time=t()
try:
while True:
time[0]=t()-start_time
print(time[0])
system('cls')
except KeyboardInterrupt:
while time[2]>=60:
time[1]=time[1]+1
time[2]=time[2]-60
while time[1]>=60:
time[0]=time[0]+1
time[1]=time[1]-60
print(time)
input('...')