""" writen by shenjackyuanjie mail: 3695888@qq.com github: @shenjackyuanjie gitee: @shenjackyuanjie """ import json import pprint from xmltodict import xmltodict json_ = { 'a': { '-abc': '123', 'bbb': [ 'a', 'b', 'c' ] } } unparse = xmltodict.unparse(json_) print(unparse) paste = xmltodict.parse(""" """) paste = json.dumps(paste) pprint.pprint(paste) print(paste) print(type(paste)) # 将paste转换成字典格式 abc = {'abc': '1234'} print(xmltodict.unparse(eval(paste))) from libs import xmltodict print(xmltodict.unparse(eval(paste)))