JSON for python
来源:互联网 发布:下载软件苹果助手 编辑:程序博客网 时间:2024/04/25 21:13
了解 json
JSON介绍
JSON官方说明
Python操作json的标准api库
练习 json
#!/usr/bin/env python#coding:utf-8"""FuncName: json.pyDesc: study json for python 2.7Date: 2016-09-06 10:30Author: johnny"""import jsondata = { 'name' : 'Johnny', 'home' : 'http://blog.csdn.net/z_johnny', 'date' : 20160906}json_str = json.dumps(data) # 字符串编码JSON数据,<type 'str'>print type(json_str)print repr(data),type(repr(data)) # 原始输出,repr(data),<type 'str'>python_dict = json.loads(json_str) # 字符串解码JSON数据,<type 'dict'>print type(python_dict)with open('jsonfile.json', 'w') as f: # 文件编码JSON数据,写JSON数据 json.dump(data, f)with open('jsonfile.json', 'r') as f: # 文件解码JSON数据,读JSON数据,<type 'dict'> data_dict = json.load(f) print type(data_dict)#带参数,example:ex = json.dumps(data,sort_keys=True,indent=4) # sort_keys 排序,indent 缩进print ex"""{ "date": 20160906, "home": "http://blog.csdn.net/z_johnny", "name": "Johnny"}"""
python原始类型向json类型的转化表:
json类型到python类型转化表:
0 0
- JSON for python
- [Python] One utility class for JSON output
- Excel 2 Json For Python In Mac
- Coursera课程Python for everyone:Quiz: REST, JSON, and APIs
- python json
- [python]json
- Python - Json
- python-json
- python json
- Python JSON
- python Json
- python json
- python json
- Python JSON
- python Json
- Python JSON
- Python & JSON
- Python json
- 回忆录
- ping 查看IP——MAC——计算机名
- 邮件服务器搭建之域名申请
- redis cluster集群搭建
- 自定义view之圆形进度条初体验
- JSON for python
- 浅析JavaScript访问对象属性和方法及区别
- Mysql读写分离的两种方法对比:Spring+JPA应用层实现 vs Amoeba中间件实现
- Automatic Preferred Max Layout Width before iOS 8.0解决办法
- PHP中单引号与双引号的区别分析
- 解决VS2013中的控制台一闪而过的问题
- Git添加多用户
- 虚函数和纯虚函数的区别
- 路边哪个楼层相对噪音会小一点?