python写xml中文本节点怎么才能不换行

Python08

python写xml中文本节点怎么才能不换行,第1张

1、在python 2.x中,在print 'xxxx' 后面加一个逗号

print 'hello world',

2、python 3.x中,需要在函数内增加一个end字段:

print('hello world', end='')

最后解决办法:

使用HTMLParser

把输出的xml转换一遍

html_parser = HTMLParser.HTMLParser()

tranform = html_parser.unescape(self.dom.toxml().decode('utf-8'))