您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Python操作json数据的一个简单例子

2025/1/9 18:47:09发布19次查看
更多的信息,可以参考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]
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product