####匹配字段 defmatch_field(txt): iftxt!='': result={} data=txt.split('|') fortmpindata: m=re.match("(.*)=(.*)",tmp) ifm!=None: #printm.group() ifm.group(1)=='usermac': result['usermac']=m.group(2)[0:17] else: result[m.group(1)]=m.group(2) returnresult原文链接:https://www.f2er.com/regex/361943.html