有时我们会遇到如何批量替换固定规律的html标签的需求,下面就是简单的解决方法
import re
d='三公<sup>2</sup>'
pattern = re.compile(r'<sup>(.*?)</sup>')
out = re.sub(pattern, '', d)
有时我们会遇到如何批量替换固定规律的html标签的需求,下面就是简单的解决方法
import re
d='三公<sup>2</sup>'
pattern = re.compile(r'<sup>(.*?)</sup>')
out = re.sub(pattern, '', d)
本文标题:Python代码库之用正则替换特殊字符(含代码demo)
本文链接:https://www.haomeiwen.com/subject/tytxjctx.html
网友评论