【问题标题】:lxml --pretty_print-- write file problemlxml --pretty_print--写入文件问题
【发布时间】:2010-12-10 08:55:53
【问题描述】:

我正在将原始数据写入 xml 文件 python 程序,在我的设计中,我们逐行获取原始数据, 然后将其写入xml文件,如:

`<root>\n
  <a> value </a>\n
  <b> value </b>\n
</root>

我第一次使用 pretty_print=True 写入 xml 文件时,我得到了我想要的,但是当第二次 当我读取文件时,获取元素根,--add-- new elemnts 然后用 pretty_print=True 将其保存回来,但我无法得到我想要的,就像:

...\n
<c> value </c></root>

` lxml有什么问题?还是我的错?

【问题讨论】:

    标签: python lxml


    【解决方案1】:

    您可能会在 lxml 常见问题解答中找到答案:Why doesn't the pretty_print option reformat my XML output?

    【讨论】:

      猜你喜欢
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-26
      • 1970-01-01
      • 2015-09-25
      相关资源
      最近更新 更多