标签:cheng style value dict key值 values int name val
#max,min,zip
people1={ ‘age1‘:123,‘age2‘:56,‘age3‘:554,‘age4‘:67,‘age5‘:234,‘age6‘:34,‘age7‘:45 } #取出key值可以知道对应值 用zip print(list(max(zip(people1.values(),people1.keys())))) print(list(zip(people1.values(),people1.keys()))) max,min 参数(可达代对象,key方法(一般用lambda表达式)) people=[ {‘name‘:‘lu‘,‘age‘:123}, {‘name‘:‘jia‘,‘age‘:134}, {‘name‘:‘cheng‘,‘age‘:143}, {‘name‘:‘lu‘,‘age‘:112} ] print(max(people,key=lambda dict:dict["age"])) sorted(可达代对象,key方法(一般用lambda表达式)) print(sorted(people,key=lambda dict:dict[‘age‘]))
标签:cheng style value dict key值 values int name val
原文地址:https://www.cnblogs.com/lujiacheng-Python/p/9612984.html