|
Revision 13, 0.8 kB
(checked in by hey, 10 months ago)
|
|
기상시각 통계
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | def timeToInt((hour,minute)): |
|---|
| 4 | if 12<hour: hour-=24 |
|---|
| 5 | return hour+minute/60.0 |
|---|
| 6 | |
|---|
| 7 | def intToTime(time): |
|---|
| 8 | hour=int(time) |
|---|
| 9 | return hour,int(round((time-hour)*60)) |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | def processTime(time): |
|---|
| 13 | return timeToInt([int(e) for e in time.split(':')]) |
|---|
| 14 | |
|---|
| 15 | def averageTime(times): |
|---|
| 16 | total=0 |
|---|
| 17 | for i in times: total+=i |
|---|
| 18 | return intToTime(total/len(times)) |
|---|
| 19 | |
|---|
| 20 | sleep=[] |
|---|
| 21 | wakeup1=[] |
|---|
| 22 | wakeup2=[] |
|---|
| 23 | insleep=[] |
|---|
| 24 | |
|---|
| 25 | for i in file('WakeUpLog.txt').readlines(): |
|---|
| 26 | times = i.split('||') |
|---|
| 27 | sleep.append(processTime(times[0])) |
|---|
| 28 | wakeup1.append(processTime(times[2])) |
|---|
| 29 | wakeup2.append(processTime(times[1])) |
|---|
| 30 | insleep.append(processTime(times[2])-processTime(times[0])) |
|---|
| 31 | |
|---|
| 32 | print averageTime(sleep) |
|---|
| 33 | print averageTime(wakeup1) |
|---|
| 34 | print averageTime(wakeup2) |
|---|
| 35 | print averageTime(insleep) |
|---|