返回一個值,我想從以下字典返回「runnerName」:從多個值的字典鑰匙在python
{u'marketId': u'1.112422365',
u'marketName': u'1m Mdn Stks',
u'runners': [{u'handicap': 0.0,
u'runnerName': u'La Napoule',
u'selectionId': 8095372,
u'sortPriority': 1},
{u'handicap': 0.0,
u'runnerName': u'Swivel',
u'selectionId': 701378,
u'sortPriority': 2},
{u'handicap': 0.0,
u'runnerName': u'Deanos Devil',
u'selectionId': 8100420,
u'sortPriority': 3},
{u'handicap': 0.0,
u'runnerName': u'Bishan Bedi',
u'selectionId': 8084336,
u'sortPriority': 4},
{u'handicap': 0.0,
u'runnerName': u'In Seine',
u'selectionId': 8199415,
u'sortPriority': 5},
{u'handicap': 0.0,
u'runnerName': u'Needs The Run',
u'selectionId': 8199416,
u'sortPriority': 6},
{u'handicap': 0.0,
u'runnerName': u'Appellez Baileys',
u'selectionId': 8148513,
u'sortPriority': 7},
{u'handicap': 0.0,
u'runnerName': u'Jessy Mae',
u'selectionId': 7652545,
u'sortPriority': 8},
{u'handicap': 0.0,
u'runnerName': u'Redy To Rumble',
u'selectionId': 7366163,
u'sortPriority': 9}]}
我已經嘗試了許多不同的方法,但無法弄清楚如何訪問值從具有多個值的密鑰開始。
'[d [ 'runnerName']爲d ['亞軍']]' – falsetru
您可能想與我們分享您嘗試的方式。我們將很樂意幫助你糾正它們:) – thefourtheye
我嘗試了類似的東西,但保持,得到一個錯誤「TypeError:列表索引必須是整數,而不是str」訪問鍵值時,只有一個我可以做,有幾個抓住我了! –