我在 Python 中有一本字典,其中人的姓氏作为键,每个键都有多个链接到它的值。有没有办法使用 for 循环遍历字典以搜索特定值,然后返回该值链接到的键?
for i in people:
if people[i] == criteria: #people is the dictionary and criteria is just a string
print dictKey #dictKey is just whatever the key is that the criteria matched element is linked to
可能还有多个匹配项,所以我需要人们输出多个键。