在工作中写程序完成任务是很快乐的事,也很有意思。哈哈
使用参数:seay.py E:/1.log
#coding = utf8 #Filename = seay.py import os import sys #特征,可以随意改,两块五一次 _tezheng = {&#39;union&#39;,&#39;select&#39;,&#39;file_put_contents&#39;} def CheckFile(_path): _f = open(_path,"r") _All_Line = _f.readlines() _f.close() _Count_Line =0 _Len_Line = len(_All_Line) _Ex_Str = &#39;&#39; print(&#39;Read Over --&#39;) while _Count_Line<_Len_Line: _Str = _All_Line[_Count_Line] for _tz_Str in _tezheng: if _tz_Str in _Str: #可以加and条件,这个贵一点,5毛一次 _Ex_Str+=_tz_Str+_Str+&#39;\r\n&#39; _Count_Line+=1 _f1 = open(_path+&#39;.seay.txt&#39;,"w") _f1.write(_Ex_Str) _f1.close() print &#39;Find Over--&#39; if len(sys.argv)==2: _File = sys.argv[1] if os.path.lexists(_File): CheckFile(_File) else: print(&#39;File does not exist!&#39;) else: print &#39;Parameter error&#39; print sys.argv[0]+&#39; FilePath&#39;
最终生成一个文件为:原文件名.seay.txt在同目录下,格式为匹配的特征+日志