例json文件,名字test.json,
{
"verson":"1.4.2" ,
"author":"johanna",
"type":"1"
}
python编码:
首先读取json文件内容,利用json.loads()转化为dict类型,遍历每一对key,val
import json
import os
try:
t_str = open('./test.json','r').read()
t_json = json.loads(t_str)
for k,v in t_json.items():
print k,v
except Exception,e:
print str(e)