实现秒表功能
import time
print('按下回车键开始计时,ctrl+c停止计时')
while True:
try:
input()
start_time = time.time()
print('开始...')
while True:
print('计时:{} 秒'.format(round(time.time() - start_time, 1)))
time.sleep(0.1)
except KeyboardInterrupt:
print('结束')
end_time = time.time()
print('总供耗时是:{}'.format(round((end_time - start_time),1)))
break