Python之max()
Python中max()函数简言之,输出为输入参数的最大值。
- 输入参数不能为多维矩阵,否则输出报错;
>>> a
array([[[ 0, 1, 2],
[ 3, 4, 5]],
[[ 6, 7, 8],
[ 9, 10, 11]]])
>>> max(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
>>> a=a.reshape(12)
>>> a
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> max(a)
11
>>>
详细解释可以参考: