开发者

BeautifulSoup removes trailing whitespace?

开发者 https://www.devze.com 2023-04-01 09:07 出处:网络
Apparently using Soup.text removes trailing whitespace for some reason.For example: In [1]: from Beautiful开发者_如何学CSoup import BeautifulSoup as Soup

Apparently using Soup.text removes trailing whitespace for some reason. For example:

In [1]: from Beautiful开发者_如何学CSoup import BeautifulSoup as Soup

In [2]: print Soup('<a href=''>a  </a>').text+ 'a'
aa

Is this intended behaviour and is there any way to stop it happening?

Edit: the desired output is

a  a


Maybe it comes from the fact that trailing whitespaces are eliminated in HTML

0

精彩评论

暂无评论...
验证码 换一张
取 消