有什么办法可以将空白的空白分配为& nbsp;在LXML或其他Python XML lib中?
我的代码是:
>>> from lxml.html import tostring, HtmlElement
>>> a = HtmlElement()
>>> a.tag = "div"
>>> a.text = " "
>>> tostring(a)
b'<div> </div>'
有什么方法可以在LXML或其他Python XML库中输出?
<div> </div>
my code is:
>>> from lxml.html import tostring, HtmlElement
>>> a = HtmlElement()
>>> a.tag = "div"
>>> a.text = " "
>>> tostring(a)
b'<div> </div>'
Is there any way to output like in lxml or other python xml library?
<div> </div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过将空白替换为'\ xa0'解决了这个问题(160是
&amp; nbsp;
ascii代码)I solved this problem by replace blank to '\xa0' (160 is
ascii code)