import json
class DictToClass(object):
def __init__(self, _obj):
if _obj:
self.__dict__.update(_obj)
txt = '{"Success": true, "ErrorCode": null, "Message": null, "Data": null, "Data555": [1, 2, 3, 4, 5]}'
TXT = DictToClass(json.loads(txt))
print(TXT.Success)
print(TXT.Data555)
Python 字典转类 dict to class
于 2022-03-16 17:14:29 首次发布