我有一个像
这样的元素节点<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Id="rId61" Target="media/image1.png"/>
我需要按顺序对属性进行排序。输出应该看起来像
<Relationship Id="rId61" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="media/image1.png"/>
我如何重新安排这个?目前我正在使用lxml库
由于
答案 0 :(得分:1)
无法使用lxml
设置元素属性的特定顺序。 element.attrib
是一个字典,python中的字典是无序集合。
另见: