json:str与dict互转

import json
a='''{"a":111,"m":2222}'''
#str--->dict
b=json.loads(a)
print(type(b))      #

a={"a":111,"m":2222}
#dict--->str
b=json.dumps(a)
print(type(b))      #
print(repr(b))      #'{"a": 111, "m": 2222}'

你可能感兴趣的:(python)