python中的 json 模块使用

(1)python 中生成 json 字符串:

import json
data = dict(ret=0, msg="Welcome, Login success!")
json_str = json.dumps(data, sort_keys=True)
print json_str

(2)python 中解析 json字符串:

import json
json_str = '{"msg": "Welcome, Login success!", "ret": 0}'
data_dict = json.loads(json_str)
print data_dict
原文地址:https://www.cnblogs.com/alenoscar/p/5248100.html