消息 [239879]
The xml.dom.minidom package has as a xml.toprettyxml() function that has the problem of altering the whitespace of the text of elements. The ElementTree module needs a prettify option that works better, perhaps something based of Effbot's code at:
http://effbot.org/zone/element-lib.htm#prettyprint
The lxml package also provides an API for this purpose:
print(etree.tostring(root, pretty_print=True)) |
|
| 日期 |
用户 |
动作 |
参数 |
| 2015-04-02 07:01:50 | rhettinger | 修改 | recipients:
+ rhettinger |
| 2015-04-02 07:01:50 | rhettinger | 修改 | messageid: <1427958110.33.0.788273316254.issue23847@psf.upfronthosting.co.za> |
| 2015-04-02 07:01:50 | rhettinger | 链接 | issue23847 messages |
| 2015-04-02 07:01:49 | rhettinger | 创建 | |
|