Created
July 31, 2012 06:47
-
-
Save syshack/3214312 to your computer and use it in GitHub Desktop.
v1 纹身日志
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| '''logfomat:2012-07-19 13:50:39,playerId:68719476740,operFlow:1,operType:0,indentify:ws:shanbiP110,sampleId:ws:shanbiP1,Level:1,Exp: | |
| 0,Num:1''' | |
| import re | |
| import time | |
| Time="2012-07-31 12:43:40" | |
| time_str=time.mktime(time.strptime(Time,"%Y-%m-%d %H:%M:%S")) | |
| def grep(file,exp): | |
| fd=open(file,'r') | |
| lines=fd.read().splitlines() | |
| fd.close() | |
| logs=[] | |
| for line in lines: | |
| if re.search(exp,line): | |
| logs.append(line) | |
| return logs | |
| def parse(): | |
| logs=grep('tattoo.log','68719510520') | |
| log_dict={} | |
| for log in logs: | |
| lines=log.split(',') | |
| log_time=time.mktime(time.strptime(lines[0],"%Y-%m-%d %H:%M:%S")) | |
| if log_time<=time_str: | |
| d={} | |
| for i in lines: | |
| d[i.split(':')[0]]=i.split(':')[1] | |
| tattoo=lines[4].split(':')[2] | |
| tattoo_num=int(d['Num'])*int(d['operFlow']) | |
| log_dict.setdefault(tattoo,0) | |
| log_dict[tattoo]+=tattoo_num | |
| return log_dict | |
| print parse() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment