Chinaunix首页 | 论坛 | 博客
  • 博客访问: 120423
  • 博文数量: 27
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 280
  • 用 户 组: 普通用户
  • 注册时间: 2012-10-15 19:04
文章分类

全部博文(27)

文章存档

2015年(1)

2014年(26)

分类: 系统运维

2015-07-02 09:26:46

转载至 http://blog.chinaunix.net/uid-9525959-id-3074355.html

更多的信息,可以参考python内部的json文档:
python>>> help(json)
或者官方文档:
style="color:#666666;font-family:宋体, Arial;line-height:26px;white-space:normal;background-color:#FFFFFF;" />
下面给出一个使用python解析json的简单例子:


点击(此处)折叠或打开

  1. #!/usr/bin/python
  2. import json
  3. #Function:Analyze json script
  4. #Json is a script can descript data structure as xml,
  5. #for detail, please refer to " style="color:#0000CC;">.

  6. #Note:
  7. #1.Also, if you write json script from python,
  8. #you should use dump instead of load. pleaser refer to "help(json)".

  9. #json file:
  10. #The file content of temp.json is:
  11. #{
  12. # "name":"00_sample_case1",
  13. # "description":"an example."
  14. #}


  15. #json string:
  16. s = json.loads('{"name":"test", "type":{"name":"seq", "parameter":["1", "2"]}}')
  17. print s
  18. print s.keys()
  19. print s["name"]
  20. print s["type"]["name"]
  21. print s["type"]["parameter"][1]

阅读(2068) | 评论(0) | 转发(0) |
0

上一篇:智能手机 UserAgent

下一篇:没有了

给主人留下些什么吧!~~