從檔案中檢索資料

以下程式碼段開啟 JSON 編碼檔案(將 filename 替換為檔案的實際名稱)並返回儲存在檔案中的物件。

import json

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