etree克隆节点 [英] etree Clone Node
本文介绍了etree克隆节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Python xml.etree
中克隆Element
对象?我正在尝试以程序方式移动和复制(然后修改其属性)节点.
How to clone Element
objects in Python xml.etree
? I'm trying to procedurally move and copy (then modify their attributes) nodes.
推荐答案
您可以只使用 copy.deepcopy()复制该元素. (顺便说一句,这也适用于lxml).
You can just use copy.deepcopy() to make a copy of the element. (this will also work with lxml by the way).
这篇关于etree克隆节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文