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

首頁 > 編程 > Python > 正文

Python操作json數(shù)據(jù)的一個(gè)簡單例子

2019-11-25 18:27:00
字體:
供稿:網(wǎng)友

更多的信息,可以參考python內(nèi)部的json文檔:
python>>> help(json)
或者官方文檔: http://docs.python.org/library/json.html#module-json.

下面給出一個(gè)使用python解析json的簡單例子:

復(fù)制代碼 代碼如下:

#!/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:關(guān)于json操作,這里再為大家推薦幾款比較實(shí)用的json在線工具供大家參考使用:

在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.VeVB.COm/code/json

JSON在線格式化工具:
http://tools.VeVB.COm/code/jsonformat

在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.VeVB.COm/code/jsoncodeformat

在線json壓縮/轉(zhuǎn)義工具:

http://tools.VeVB.COm/code/json_yasuo_trans

C語言風(fēng)格/HTML/CSS/json代碼格式化美化工具:
http://tools.VeVB.COm/code/ccode_html_css_json

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 轮台县| 永新县| 武隆县| 拜城县| 绍兴市| 南汇区| 晋江市| 淄博市| 抚顺市| 吴旗县| 旌德县| 平安县| 泌阳县| 特克斯县| 嘉兴市| 大姚县| 克东县| 永川市| 肃南| 镇赉县| 美姑县| 马尔康县| 蒲城县| 顺昌县| 阿拉尔市| 高台县| 潼南县| 梨树县| 奇台县| 鲁山县| 阳原县| 乌什县| 杭锦旗| 广汉市| 海盐县| 铁力市| 山阳县| 曲靖市| 凌云县| 慈利县| 远安县|