最佳答案
您正在使用find()
,它仅返回找到的第一个匹配项。这就是为什么您可以看到第一个 strong
消失了,但第二个没有消失。使用 find_all()
代替,这将删除所有 strong
标记。
for strong in soup.find_all('strong'):
strong.decompose()
关于python - .decompose() 后标签未删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48483454/