标签:lis tom min 默认 span bsp col cat lambda
age={‘tom‘:18,‘cat‘:19,‘jerry‘:30,‘dog‘:12} # print(max(age.values())) # print(min(age.values())) # print(max(age))#字典默认比较的是key # for i in zip(age.values(),age.keys()): # print(i) print(list(min(zip(age.values(),age.keys()))))#zip实现value和key的互换 #不同类型间不能比较
people=[ {‘name‘:‘cat‘,‘age‘:14}, {‘name‘:‘dog‘,‘age‘:88}, {‘name‘: ‘tom‘, ‘age‘: 33}, ] print(‘取出来‘,max(people,key=lambda dic:dic[‘age‘]))#取出来最大额一个值 print(‘取出来‘,min(people,key=lambda dic:dic[‘age‘]))
标签:lis tom min 默认 span bsp col cat lambda
原文地址:https://www.cnblogs.com/wfl9310/p/8969687.html