Python全栈开发——内置函数

#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']))

 

 
posted @ 2018-09-09 11:19  lujiacheng-python  阅读(141)  评论(0编辑  收藏  举报