国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

Python操作json數據的一個簡單例子

2020-02-23 05:19:53
字體:
來源:轉載
供稿:網友

更多的信息,可以參考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]

PS:關于json操作,這里再為大家推薦幾款比較實用的json在線工具供大家參考使用:

在線JSON代碼檢驗、檢驗、美化、格式化工具:
http://tools.jb51.net/code/json

JSON在線格式化工具:
http://tools.jb51.net/code/jsonformat

在線XML/JSON互相轉換工具:
http://tools.jb51.net/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉換工具:
http://tools.jb51.net/code/jsoncodeformat

在線json壓縮/轉義工具:

http://tools.jb51.net/code/json_yasuo_trans

C語言風格/HTML/CSS/json代碼格式化美化工具:
http://tools.jb51.net/code/ccode_html_css_json

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 扎囊县| 开原市| 壤塘县| 神池县| 上栗县| 天水市| 宁晋县| 威远县| 邢台县| 通渭县| 香河县| 鸡东县| 分宜县| 孙吴县| 夏津县| 黑龙江省| 青冈县| 威信县| 炎陵县| 克什克腾旗| 蒲城县| 南郑县| 车险| 德江县| 保德县| 林西县| 广德县| 砚山县| 会理县| 绥江县| 酒泉市| 龙里县| 海南省| 湖南省| 阜宁县| 清丰县| 江阴市| 朝阳县| 福州市| 天长市| 龙口市|