在 Python 中漂亮地打印 XML 的最佳方式(或各种方式)是什么?
原文由 Hortitude 发布,翻译遵循 CC BY-SA 4.0 许可协议
在 Python 中漂亮地打印 XML 的最佳方式(或各种方式)是什么?
原文由 Hortitude 发布,翻译遵循 CC BY-SA 4.0 许可协议
lxml 是最新的,已更新,并包含漂亮的打印功能
import lxml.etree as etree
x = etree.parse("filename")
print etree.tostring(x, pretty_print=True)
查看 lxml 教程:http: //lxml.de/tutorial.html
原文由 1729 发布,翻译遵循 CC BY-SA 3.0 许可协议
2 回答5.1k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
1 回答6.2k 阅读✓ 已解决
4 回答974 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
1 回答1.7k 阅读✓ 已解决