jzztf / wiki

wiki
https://jzztf.github.io
Other
1 stars 0 forks source link

py-mo-json #29

Open jzztf opened 6 years ago

jzztf commented 6 years ago

python模块json

python的json模块

dumps()函数写入json

import json

python_value = {'zhanghua': 78,'lili':89,'xiaohong':False}
json_data = json.dumps(python_value)
json_data
# ==> '{"zhanghua": 78, "lili": 89, "xiaohong": false}'

loads()函数读取json

py_value = json.loads(json_data)
py_value
# ==> {'lili': 89, 'xiaohong': False, 'zhanghua': 78}