以下是我的代码段。我试图从嵌套列表中的嵌套字典中提取'string'和'score'的值。我该怎么做?
预期输出为“对象元素”和“ 1.0”
[{'Form': [{'string': 'object element', 'score': 1.0,}],
'types': ['http://google.com'],
'threshold':34}]
答案 0 :(得分:3)
这应该有效
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'])