Python日志查询
来源:互联网 发布:点击进入f2c最新域名 编辑:程序博客网 时间:2024/06/03 16:57
#!/usr/bin/python#-*- coding: UTF-8 -*-import os, sys, string, codecs# 设置字符集reload(sys)sys.setdefaultencoding("utf-8")# 将比赛ID, 玩家id加入def AddMapKeySetVal(Map, Key, Val): if Map.has_key(Key): Map[Key].add(Val) else: Map[Key] = set() Map[Key].add(Val)def RemoveOneVal(Map, Key, Val): if Map.has_key(Key): Map[Key].discard(Val)def RemoveKey(Map, Key): if Map.has_key(Key): del Map[Key]def PrintMap(file, Map): count = 0 line = "" userDic = {}; userList = []; for (Key, Val) in Map.items(): for userid in Val: line += "%s\n" % userid count += 1; if count%100 == 0: #print line file.write(line) line = "" file.write(line)# 获取长字符串中,两个字符串中间的值def getValue(srcStr, destStr1, destStr2): start = srcStr.find(destStr1) + len(destStr1) end = -1 if destStr2 != "": end = srcStr.find(destStr2) return srcStr[start:end]#处理matchserverlogdef handleMatchserverLog(fileName): matchDic = {} file = open(fileName) for line in file: # 处理用户加入的比赛 if line.find("user join match delcard, cardCount") > -1: matchId = getValue(line, "matchId:", ", userId:") userId = getValue(line, " userId:", "") AddMapKeySetVal(matchDic,matchId,userId) if line.find("user quit match addcard, cardCount") > -1: matchId = getValue(line, " matchId:", ", userId:") userId = getValue(line, " userId:", "") RemoveOneVal(matchDic, matchId, userId) if line.find("FinalRankingInfo matchID") > -1: matchId = getValue(line, " matchID:", " Order:") RemoveKey(matchDic, matchId) output = open('AddCardUserd_new.txt','a') PrintMap(output,matchDic) #print matchDicfileName = "2017-08-10_MatchServer(1).log"handleMatchserverLog(fileName)
阅读全文
0 0
- Python日志查询
- mysql 慢日志查询模块的测试[python]
- MySQL日志--查询日志
- python 日志
- python 日志
- Python日志
- python日志
- Python日志
- python日志
- Python 日志
- Mysq日志管理(错误日志、查询日志、慢查询日志)
- 日志-Mysql慢日志查询
- mssql2k查询IIS日志
- CLI 日志查询
- 记录XPO查询 日志
- 如何查询MySql日志
- MYSQL - 慢查询日志
- 分析慢查询日志
- ubuntu完全卸载mysql
- 响应式布局之相对浏览器垂直居中
- python---pandas.merge使用
- dp 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额。
- YARN资源管理的最佳实践
- Python日志查询
- 自己制作GitHub开源项目的代码仓库的经验——直接compile自己的代码包【开源】
- 在龙芯1C上移植硬浮点FPU到RT-Thread
- JeePlus后台JSP页面编写指南
- 面试
- luogu3856 [TJOI2008]公共子串(dp)
- Python数据库查询
- SVN工具使用问题及解答汇总
- WebView使用详解(一)——Native与JS相互调用(附JadX反编译)