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]
还是必须手动循环?
目前没有回答
相关问题 更多 >
编程相关推荐