import xml.etree.ElementTree as ET
fileXml ='C:\\Users\\Documents\\config.xmlroot.insert(1, comment) # 1 is the index where comment is inserted print(&q
我正在向一个大型xml文件中插入一个元素。我希望插入的元素位于顶部(所以我需要使用root.insert方法,不能仅仅附加到文件中)。我还希望元素的格式与文件的其余部分相匹配。</a>import xml.etree.ElementTree as ET
xmlfile = ET.parse('file.xml<