博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用python解析json文件
阅读量:6974 次
发布时间:2019-06-27

本文共 689 字,大约阅读时间需要 2 分钟。

  hot3.png

官方文档:

#!/usr/bin/pythonimport 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 sprint s.keys()print s["name"]print s["type"]["name"]print s["type"]["parameter"][1]

转载于:https://my.oschina.net/yoke/blog/163813

你可能感兴趣的文章
系统升级与优化
查看>>
网络编程之urllib
查看>>
Simple Python Dictionary :)
查看>>
c语言程序设计第六次作业--循环结构(二)
查看>>
【转】WebView的JavaScript与本地代码三种交互方式
查看>>
xml转换为对象 微信接口
查看>>
软件产品案例分析
查看>>
HTML表单
查看>>
四元数
查看>>
bzoj2125: 最短路
查看>>
P4781 【模板】拉格朗日插值
查看>>
jzoj5984. 【北大2019冬令营模拟2019.1.1】仙人掌 (分块)
查看>>
python jenkins api
查看>>
电梯调度算法的实现
查看>>
IIPC--share memory
查看>>
前端之html5和css3
查看>>
View绘制机制
查看>>
跟KingDZ学HTML5之四 继续探究Canvas之路径
查看>>
054_VisualForce Ajax 01
查看>>
Android性能优化问题总结
查看>>