Python 美联将分离;nbsp和;在html标记中

Python 美联将分离;nbsp和;在html标记中,python,beautifulsoup,Python,Beautifulsoup,我的代码 >>来自bs4导入组 ... html=“1.08 8.00 151.00” ... soup=BeautifulSoup(html,“lxml”) >>>打印(soup.find('td').text) 1.08  8.00  151.00 >>>nums=soup.find('td').text.split() >>>努姆斯 ['1.08', '8.00', '151.00'] >>> ' ; '.加入(nums) '1.08 ; 8.00 ; 151.00' html = "&

我的代码

>>来自bs4导入组
... html=“1.08 8.00 151.00”
... soup=BeautifulSoup(html,“lxml”)
>>>打印(soup.find('td').text)
1.08  8.00  151.00
>>>nums=soup.find('td').text.split()
>>>努姆斯
['1.08', '8.00', '151.00']
>>> ' ; '.加入(nums)
'1.08 ; 8.00 ; 151.00'
html = "<td>1.08&nbsp; 8.00&nbsp; 151.00</td>"
from bs4 import BeautifulSoup

print BeautifulSoup(html,"lxml").renderContents()
<html><body><td>1.08  8.00  151.00</td></body></html>
1.08 ; 8.00 ; 151.00 ;    
>>> from bs4 import BeautifulSoup
... html = "<td>1.08&nbsp; 8.00&nbsp; 151.00</td>"
... soup = BeautifulSoup(html, "lxml")
>>> print(soup.find('td').text)
1.08  8.00  151.00
>>> nums = soup.find('td').text.split()
>>> nums
['1.08', '8.00', '151.00']
>>> ' ; '.join(nums)
'1.08 ; 8.00 ; 151.00'