📜  python max key dictionary key getter - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:35.584000             🧑  作者: Mango

代码示例3
from operator import itemgetter

items = [
    {'a': 1, 'b': 99},
    {'a': 2, 'b': 88},
    {'a': 3, 'b': 77},
]

print(max(items, key=itemgetter('a')))
print(max(items, key=itemgetter('b')))