您的位置:首页 > 编程语言 > Python开发

python中的 json 模块使用

2016-05-12 12:02 567 查看
(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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: