-
Notifications
You must be signed in to change notification settings - Fork 9
/
stopwatch.py
31 lines (30 loc) · 706 Bytes
/
stopwatch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#! python3
#stopwatch.py -
#Usage:
#
#Author : qmeng
#MailTo : [email protected]
#QQ : 1163306125
#Blog : http:https://blog.csdn.net/Mq_Go/
#Create : 2018-02-13 16:18:46
#Version: 1.0
#
import time
print('Press ENTER to begin.Afterwards,\npress ENTER to "click" the stopwatch \nPress Ctrl+C to quit.')
input()
print('Started...')
startTime = time.time()
lastTime = startTime
lapNum = 1;
#记录并打印单圈时间
try:
while True:
input()
temp = time.time()
lapTime = round(temp-lastTime,2)
lastTime = temp
totalTime = round(time.time()-startTime,2)
print('第 %s 圈,用时 %s 秒,总用时 %s 秒'%(lapNum,lapTime,totalTime))
lapNum += 1
except KeyboardInterrupt:
print('\nDone')