如何在嵌套的somedict中搜索子字符串“钢铁侠”后才返回“key\u three”。目标是如果找到"Iron man"
,则返回“key三”[key][dictionary having->;**]的所有父字典类型值,即including key_three_one:[values], key_three_two:[values]
和第三个dictionary元素{}。你知道吗
somedict = [
{
"anyKey":1,
"key_two":2,
**{ #key_three/value of key_three is nothing but a dictionary.
key_three_one: "spiderman",
key_three_two:"superman",
"key_three_three":{
"from_asguard" : "is not Iron Man:batman"
}
}**
}]
我已经浏览了以下链接: 1Python return dictionary 2Iterate through a nested Dictionary and Sub Dictionary in Python 三。Loop through all nested dictionary values? 4Python function return dictionary?。你知道吗
遍历
somedict
列表中的字典项也可以使用列表理解:
相关问题 更多 >
编程相关推荐