设为首页 加入收藏

TOP

python中的 json 模块使用
2017-09-30 13:33:12 】 浏览:8826
Tags: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

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Python使用报错记录 下一篇python 之文件操作

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目