python去除所有html标签的方法

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)

你可能感兴趣的:(python去除所有html标签的方法)