Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 XML 文件上附加一个新的孩子,问题是在将其插入 XML 文档之前,我无法为孩子提供适当的格式。
我用书籍创造了minidom.Document()孩子appendChild。
minidom.Document()
appendChild
我解释得好吗?
提前致谢。
XML 片段的缩进对于 XML 处理器来说是一项棘手的工作:它们可以执行许多您意想不到的转换,并且不允许在未经您明确同意的情况下以您希望的方式重新缩进元素。
查看Pretty printing XML in Python了解如何缩进完整的 XML 文档。