我正在尝试使用以下代码转换 HTML 中的标签:`
for tag in soup.find_all("a"):
text_href = tag.get_text()
if text_href !='' :
text_href = text_href+'|'
else:
text_href=''
tag.insert(0,'['+text_href+tag.get('href')+']')
tag.unwrap()
但是在关闭 ]
后文本 href 被复制不知道为什么会发生这种情况