如果我想在python中创建XML文件以显示软件名称和版本,我该怎么办?
for i in range (50):
try:
subkey=EnumKey(akey,i)
asubkey = OpenKey(akey, subkey)
#print subkey
val=QueryValueEx(asubkey,"DisplayName")
var=QueryValueEx(asubkey,"DisplayVersion")
#print val
#print var
if val != '' and var != '':
the_doc = ROOT(
DOC(
Name(val, DisplayName='Name'),
Version(var, DisplayVersion='Version')
)
)
f.write(lxml.etree.tostring(the_doc, pretty_print=True, xml_declaration=False))
else:
print "Registry empty"
except:
print " "
f.close()
except:
print "File not available"