python 字典输出最大、最小value对应的key

prices = {'a':1, 'b':7, 'c':5, 'd':10, 'e':12, 'f':3}
result_max = max(price,key=lambda x:prices[x])
print(f'max:{result_max}') ## e
result_min = min(price, key=lambda x:prices[x])
print(f'min:{result_min}')  ## a

posted @ 2021-11-24 17:48  Seven_lv  阅读(587)  评论(0)    收藏  举报