from bs4 import BeautifulSoup
s = '''
/usr/sbin/tgt-admin <span class="token comment">#配置工具</span>/usr/sbin/tgtadm <span class="token comment">#管理target工具</span>/usr/sbin/tgtd <span class="token comment">#服务进程程序</span>/usr/sbin/tgtimg <span class="token comment">#共享的映射文件设备工具</span></code></pre><div class="toolbar"></div></div>
'''
bs = BeautifulSoup(s,"html.parser")
for tag in bs.find_all(): #tag.name是find_all找出来的标签的标签名字
if tag.name in ["script","link"]: #如果html标签名字在列表里进行删除
tag.decompose() #删除其内容
转载于:https://blog.51cto.com/song1230/2326016