正则表达式sub,findall,split,match,re.compile()
1.sub(规则,替换成的变量, 所要替代的变量)
ret = re.sub(r"\d+", '998', "python = 997") # 998
s = re.sub('\d', "s", "123p") # sssp
2.findall(规则,搜寻的变量)
ret = re.findall(r"\d+", "python = 9999, c = 7890, c++ = 12345")...
原创
2019-09-19 21:53:00 ·
236 阅读 ·
0 评论