相关疑难解决方法(0)

在嵌套的Python字典中搜索密钥

我有一些像这样的Python词典:

A = {id: {idnumber: condition},.... 
Run Code Online (Sandbox Code Playgroud)

例如

A = {1: {11 : 567.54}, 2: {14 : 123.13}, .....
Run Code Online (Sandbox Code Playgroud)

我需要搜索字典中是否有任何字典idnumber == 11并使用condition.但如果在整个字典中没有idnumber == 11,我需要继续下一个字典.

这是我的尝试:

for id, idnumber in A.iteritems():
    if 11 in idnumber.keys(): 
       calculate = ......
    else:
       break
Run Code Online (Sandbox Code Playgroud)

python recursion dictionary nested

5
推荐指数
2
解决办法
8655
查看次数

标签 统计

dictionary ×1

nested ×1

python ×1

recursion ×1