2017-05-05 72 views
-6

我有以下的嵌套字典:如何使用子鍵訪問嵌套字典的值?

{ 
    "category": "string", 
    "top_bottom": { 
    "count": 0, 
    "data": [ 
     { 
     "store_name": "string", 
     "store_id": "string", 
     "value": 0 
     } 
    ], 
    "end_name": "string" 
    } 
} 

而且我想要得到的關鍵store_name值。我怎樣才能做到這一點?

回答

0

你總是需要知道「完整路徑」才能到達那裏。所以,如果你的字典被稱爲myDict,例如,你有

myDict["top_bottom"]["data"][0]["store_name"] 

那裏如果你不知道的方式「完整路徑」,它可能是考慮不同結構的好主意,你的數據。