#!/usr/bin/python
# -*- coding: utf-8 -*-
#RUN // 程序启动
#EXIT // 程序退出
#START // 热点启动
#STOP // 热点停止
#ONL // 客户端上线
#OFFL // 客户端下线
#INSTALL //安装
#UNINSTALL //卸载
import re
#模式匹配UUID
patternUid=re.compile(r‘(\w){8}-(\w){4}-(\w){4}-(\w){4}-(\w){12}‘)
#定义Uid字典,用来排重
uid={}
#用来统计各种动作的次数
actionCount={
"a=RUN":0,
"a=EXIT":0,
"a=START":0,
"a=STOP":0,
"a=ONL":0,
"a=OFFL":0,
"a=INSTALL":0,
"a=UNINSTALL":0
}
for k,v in actionCount.iteritems():
with open("C:/Users/Administrator/Desktop/python/result.txt") as f:
for line in f:
if patternUid.search(line):
uidName=patternUid.search(line).group()
if k in line:
if uid.has_key(uidName):
pass
else:
uid[uidName]=1
actionCount[k]+=1
for k,v in actionCount.iteritems():
print k ,actionCount[k]本文出自 “记录点滴” 博客,请务必保留此出处http://caozm.blog.51cto.com/1118764/1584955
原文:http://caozm.blog.51cto.com/1118764/1584955