如何从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'])

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章