http://python101.pythonlibrary.org/chapter23_xml.html ElementTree 创建 import xml . etree . ElementTree as xml def createXML ( filename ) : """ Create an example XML file """ root = xml . Element ( "zAppointments" ) appt = xml . Element ( "appointment" ) root. append ( appt ) # add appointment children begin = xml . SubElement ( appt , "begin" ) begin. text = "1181251680" uid = xml . SubElement ( appt , "uid" ) uid. text = "040000008200E000" alarmTime = xml . SubElement ( appt , "alarmTime" ) alarmTime. text = "1181572063" state = xml . SubElement ( appt , "state" ) ...