首页 > 自动化运维 > DevOps > Python 查找字典中最大最小值的key
>>> char_count = {'lower_count': 5, 'upper_count': 3, 'number_count': 0, 'special_count': 0}
>>> min_count_key = min(char_count, key=char_count.get)
>>> max_count_key = max(char_count, key=char_count.get)
>>> print(min_count_key)
number_count
>>> print(max_count_key)
lower_count
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31560527/viewspace-2681129/ ,如需转载,请注明出处,否则将追究法律责任。