python去除所有html标签的方法

2021-05-25  本文已影响0人  还是那个没头脑
import re
with open('./sample_x.txt', 'r') as x:
    content_x = x.read()

    pre = re.compile(r'<[^>]+>',re.S)
    str = pre.sub('',content_x)
    print(str)
上一篇 下一篇

猜你喜欢

热点阅读