如何在field1.text
不编写完整文件的情况下仅更改元素的文本?(蟒蛇2.5)。
import xml.etree.cElementTree as ET
import urllib2
import os
file("c:\Python25\wxTime.xml", 'w')
root = ET.Element("root")
doc = ET.SubElement(root, "doc")
field1 = ET.SubElement(doc, "wxpageTime")
field1.set("name", "lastUpdate")
field1.text = "Thu May 10 02:00:00 2012"
tree = ET.ElementTree(root)
tree.write("c:\Python25\wxTime.xml")