- 论坛徽章:
- 13
|
py版的- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- def ati(s):
- return int(s.split(':')[0]) * 3600 + int(s.split(':')[1]) * 60 + int(s.split(':')[2])
- def bti(s,t):
- print"%s,%02d:%02d:%02d"%(s,t/3600,t%3600/60,t%60)
- for line in open('file'):
- sum,h=0,3600
- start,end1,end2=8*h,17.5*h,18*h
- s,t=line.split()[1],line.split()[2]
- x,y=ati(s),ati(t)
- if x < start:
- x=start
- if y >= end1 and y <= end2:
- sum=end1-x-1.5*h
- if y > end2:
- sum=y-x-1.5*h-0.5*h
- bti(line.split()[0],sum)
复制代码 [root@ py]$ python 4.py
2013-07-15,07:45:18
2013-07-12,07:47:39
2013-07-11,07:57:03
2013-07-10,08:07:17
2013-07-09,08:00:00
2013-07-08,07:32:32
2013-07-05,07:49:40
2013-07-04,09:45:24
2013-07-03,10:02:34
2013-07-02,09:52:38
2013-07-01,07:38:14 |
|