Python 3 内置函数 - max()
函数
0. max()
函数
返回最大值,参数可以为序列。
1. 使用方法
>>> help(max)
# output:
Help on built-in function max in module builtins:
max(...)
## 使用方法
max(iterable, *[, default=obj, key=func]) -> value
max(arg1, arg2, *args, *[, key=func]) -> value
With a single iterable argument, return its biggest item. The
default keyword-only argument specifies an object to return if
the provided iterable is empty.
With two or more arguments, return the largest argument.
2. 使用示例
示例1.
>>> max(0,1,2,9)
# output:
9
示例2.
>>> list(range(5)), max(range(5))
# output:
([0, 1, 2, 3, 4], 4)