繁体   English   中英

如何从python嵌套列表中的嵌套字典中提取值

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM