xmltodict模块

python xml_str转json

使用第三方模块xmltodict

pip3 install xmltodict

使用:

import xmltodict

def xmlToJson(xml_str):
    '''传入xml字符串,返回字典'''
    dic = xmltodict.parse(xml_str, encoding='utf-8')
    return dic
原文地址:https://www.cnblogs.com/dxnui119/p/15562624.html