Skip to main content
 首页 » 编程设计

python之按值索引python字典

2025年05月04日11txw1958

<分区>

Possible Duplicate:
Inverse dictionary lookup - Python

在 Python 中是否有内置的按值索引字典的方法。

例如像这样的东西:

dict = {'fruit':'apple','colour':'blue','meat':'beef'} 
print key where dict[key] == 'apple' 

或:

dict = {'fruit':['apple', 'banana'], 'colour':'blue'} 
print key where 'apple' in dict[key] 

还是我必须手动循环播放?