在这里找到:- 将 Python 字典序列化为 XMLI am using dicttoxml in python for converting dict to XML .I need to convert the dict to XML attributes.For example:dict[ { "@name":"Ravi", "@age":21, "college":"Anna University" }]Output XML<Student name="Ravi" age=21> <college>Anna University</college></Student>codedicttoxml(dict, custom_root='Student', attr_type=False, root=True)Actual Output<Student> <key name="name">Ravi</key> <key name="age">21</key> <college>Anna University</college></Student> 解决方案 This is not supported by dicttoxml as of yet, though the issue has been open from a long time.https://github.com/quandyfactory/dicttoxml/issues/27Though if your needs are not that complex, you can try this simple serializer out.https://gist.github.com/reimund/5435343/found it here :- Serialize Python dictionary to XML 这篇关于使用属性将 dict 转换为 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-23 07:16