从文件中检索数据

以下代码段打开 JSON 编码文件(将 filename 替换为文件的实际名称)并返回存储在文件中的对象。

import json

with open(filename, 'r') as f:
    d = json.load(f)