# 字典和json 格式 的对比
p_dict={'name':'fqs','age':18}
p_json='{"name":"fqs","age":18}'
# 1 将字典转为json格式
import json
result1=json.dumps(p_dict)
print(result1,type(result1))
'''
{"name": "fqs", "age": 18} <class 'str'>
'''
# 2 将json转为字典格式
result2=json.loads(p_json)
print(result2,type(result2))
'''
{'name': 'fqs', 'age': 18} <class 'dict'>
'''
标签:name,18,age,json,fqs,格式,字典 From: https://www.cnblogs.com/haha1988/p/17541875.html