import re
#re 预编译
pat=re.compile("(.*)----(.*)") #预编译可以加快速度
line="827007914----penghueix"
matchobj=pat.match(line)
print(matchobj.group()) #matchobj.group()等价matchobj.group(0)
print(matchobj.group(0)) #827007914----penghueix
print(matchobj.group(1)) #827007914
print(matchobj.group(2)) #penghueix
Python match 的第二种风格,预编译(compile)
最新推荐文章于 2021-07-11 21:17:58 发布