re.sub提取替换字符
text ='<h1 align=left”class=~nnn”>姓名:李隆基</h1><h3 align=~right”class="mum>打开第三方坤宁宫</h3>' import re htm = re.findall(r"<h.*?</h\d>",text) print(htm) for t in htm: k = re.sub("<h.*?>",'',t) print(k)
text ='<h1 align=left”class=~nnn”>姓名:李隆基</h1><h3 align=~right”class="mum>打开第三方坤宁宫</h3>' import re htm = re.findall(r"<h.*?</h\d>",text) print(htm) for t in htm: k = re.sub("<h.*?>",'',t) print(k)
评论