@TOC
max
max(iterable, *[key, default])
max(arg1, arg2, args[, key])
返回迭代对象中的最大值,其中key参数的作用是对迭代对象中的每个元素先用key指定的函数进行处理,然后取最大值
Return the largest item in an iterable or the largest of two or more arguments.
其中key指定的函数可以是库里的,也可以是自定义的
1. python内置函数
1 | list_ = [1, 3, 6, 4, -5, -10] |
2. 自定义函数
1 | def func(x): |
3. 匿名函数
1 | list_ = [1, 3, 6, 4, -5, -10] |
4. 一些方法
1 | # 找出出现次数最多的数 |