匹配去掉html标签

import re

html = """<p style="text-align:left;"><span style="font-size:12.0pt;font-family:KaiTi;">注意:DAG未来6个月会有6次空投,空投数量总共为3000万个,请用户知悉!</span></p>"""

p = re.compile('<[^>]+>') 

print (p.sub("", html))
# [^>] 是匹配除了>的所有字符
# + 表示贪婪模式

猜你喜欢

转载自blog.csdn.net/legendary_dragon/article/details/80731823