我在 python 中使用 BeautifulSoup 解析 html
我不知道如何在提取文本元素时插入空格
这是代码:
import BeautifulSoup
soup=BeautifulSoup.BeautifulSoup('<html>this<b>is</b>example</html>')
print soup.text
那么输出是
这是例子
但我想在其中插入一个空格
是的,就是例子
如何插入空格?
Use getText
反而:
import BeautifulSoup
soup=BeautifulSoup.BeautifulSoup('<html>this<b>is</b>example</html>')
print soup.getText(separator=u' ')
# u'this is example'
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)