[英]How to extract the value from a nested dictionary within a nested list in python
以下是我的代碼段。 我試圖從嵌套列表中的嵌套字典中提取'string'和'score'的值。 我該如何完成?
預期的輸出將是“對象元素”和“ 1.0”
[{'Form': [{'string': 'object element', 'score': 1.0,}],
'types': ['http://google.com'],
'threshold':34}]
這應該工作
data = [{'Form': [{'string': 'object element', 'score': 1.0,}], 'types': ['http://google.com'], 'threshold':34},{'Form': [{'string': 'data store', 'score': 0.9,}], 'types': ['http://google.com'], 'threshold':23}]
for d in data:
print(d['Form'][0]['string'])
print(d['Form'][0]['score'])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.