python处理json

JSON文件初览:

该json对象有一个键:“Schedule”,这个键对应的值也是个“映像”,有4个键

分别是“conferences”,"events","speakers","venues",这4个键对应的值都是一个记录列表,各个列表都有一条记录。

使用python解析json文件

 使用json.load函数解析JSON文件,返回Python原生对象:

import json
def load():
    with open(JSON) as fp:   
        return json.load(fp)

 审查数据源的字段

>>>feed=load()
>>>sorted(feed['Schedule'].keys())
['conferences','events','speakers','venues']
>>>feed['Schedule']['speakers'][-1]['name']
'Carina C.Zona'
原文地址:https://www.cnblogs.com/liuguangshou123/p/13588031.html