經安全檢測,此網站為安全網站,請放心前往原始網址!

python - get key by value in dictionary - Stack Overflow

If you want both the name and the age, you should be using .items() which gives you key (key, value) tuples: for name, age in mydict.items(): if age == search_age: print name You can unpack the tuple into two separate variables right in the for loop, then

stackoverflow.com

網址安全性掃描由 google 提供