使用python解析json文件
2013-06-24 15:23
736 查看
更多的信息,可以参考python内部的json文档:
python>>> help(json)
或者官方文档:
http://docs.python.org/library/json.html#module-json
下面给出一个使用python解析json的简单例子:
#!/usr/bin/python
import json
#Function:Analyze json script
#Json is a script can descript data structure as xml,
#for detail, please refer to
"http://json.org/json-zh.html".
#Note:
#1.Also,
if you write json script
from python,
#you should use dump instead of load. pleaser refer to
"help(json)".
#json file:
#The file content of temp.json
is:
#{
# "name":"00_sample_case1",
# "description":"an example."
#}
#f = file("temp.json");
#s = json.load(f)
#print s
#f.close
#json string:
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>>> help(json)
或者官方文档:
http://docs.python.org/library/json.html#module-json
下面给出一个使用python解析json的简单例子:
#!/usr/bin/python
import json
#Function:Analyze json script
#Json is a script can descript data structure as xml,
#for detail, please refer to
"http://json.org/json-zh.html".
#Note:
#1.Also,
if you write json script
from python,
#you should use dump instead of load. pleaser refer to
"help(json)".
#json file:
#The file content of temp.json
is:
#{
# "name":"00_sample_case1",
# "description":"an example."
#}
#f = file("temp.json");
#s = json.load(f)
#print s
#f.close
#json string:
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解析json文件
- 使用python解析json文件(转)
- 使用python解析json文件 分类: python 小练习 2014-03-21 18:17 354人阅读 评论(0) 收藏
- 使用Python解析JSON文件
- 使用python解析json文件
- 使用python解析json文件
- Python解析Json,批量copy文件到指定目录脚本
- 使用python解析Json字符串-获取Json字符串关键字
- swift:使用第三方开源库SwiftyJSON解析本地json数据文件
- Python中使用ConfigParser解析ini配置文件实例
- 在c++中使用json----保存到文件、从文件中解析
- python cookbook第三版学习笔记七:python解析csv,json,xml文件
- 使用.NET4.0的dynamic特性解析plist文件及json字符串
- 零基础学python-13.4 文件上使用列表解析与列表解析扩展
- Python更快的解析JSON大文件
- 【Python】配置文件解析模块ConfigParser使用实例
- python解析json文件
- Python解析json文件相关知识学习
- python使用ConfigParse解析配置文件
- 使用coffeescript定时任务下载服务器xml和plist文件解析为json