概述
input : this is test <b> bold text </b> normal text expected output: this is test normal text
from BeautifulSoup import BeautifulSoup def removeTag(soup,tagname): for tag in soup.findAll(tagname): contents = tag.contents parent = tag.parent tag.extract() s = BeautifulSoup("abcd <b> btag </b> hello <d>dtag</d>") removeTag(s,"b") print s removeTag(s,"d") print s
收益:
>>> abcd hello <d>dtag</d> abcd hello
总结
以上是编程之家为你收集整理的带标签python全部内容,希望文章能够帮你解决带标签python所遇到的程序开发问题。
如果您也喜欢它,动动您的小指点个赞吧