def write_xlsx_to_xml(datadict, savename):
# ??dom??
doc = Document()
# ?????
root = doc.createElement('root')
# ??student??
student = doc.createElement('city')
# ?????dom?
doc.appendChild(root)
# ?student????????
root.appendChild(student)
# ????
comment = doc.createComment('\n ????\n')
student.appendChild(comment)
# ????
text_node = doc.createTextNode(str(datadict))
student.appendChild(text_node)
# ???xml??
with open(savename, 'w', encoding='utf-8') as f:
doc.writexml(f, addindent=' ', newl='\n', encoding='utf-8')
评论列表
文章目录