Python正则表达式测试:
import re import sys if len(sys.argv) < 3: print("lack of argument\nusage: python reg.py passwd.txt") sys.exit() #keyword=re.compile(r'''travel+ed''') keyword=re.compile(sys.argv[2]) aa=open(sys.argv[1],"r") bb=aa.readlines() #print(bb) for line in bb: #print(line) data=re.findall(keyword,line) #print("data:%s,length:%d,type:%s" %(data,len(data),type(data))) if len(data)>0: for i in range(0,len(data)): if type(data[0])=="builtins.str": print(data[i]) aa.close()Python正则表达式测试
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/61622a235825c94a2881f65950fd8770.html