每天一篇python: json对象操作
2016-04-05 22:36
567 查看
使用python操作json
#!/usr/local/bin/python2.7 # -*- coding:utf-8 -*- ''' Created on 2016年4月5日 python 操作json数据 @author: damuou ''' import json #1: 定义json字符串 json_str={"name": "lilei","sex": 'man',"age": 18} print json_str #把一个Python对象编码转换成Json字符串 print json.dumps(json_str) #把Json格式字符串解码转换成Python对象 s = json.loads('{"name":"test", "type":{"name":"seq", "parameter":["1", "2"]}}') print s print s.keys() print s["name"] print s["type"]["name"] print s["type"]["parameter"][1]
这几天没状态。。。。
相关文章推荐
- Python图片验证码
- Windows 下 Python 环境搭建
- Python 环境搭建
- python小技巧及速度提高
- Python Twisted架构英文版
- PyChram工具pdb调试python代码
- 此变量非彼变量(python变量)
- python动态获取对象的属性和方法
- Python 简史
- Python 简介
- Python 高级编程技巧
- 利用爬虫获取豆瓣上可能喜欢的书籍
- 我的Python学习之路之基本语法-列表和字典
- 学习Python
- 学习Python
- 学习Python
- 学习Python
- Python ** operator vs math.pow
- python 学习笔记
- python执行环境