Python 内建函数 - min(iterable, *[, key, default])
2017-03-20 11:07
561 查看
参数形式
Manual
直译
实例
拓展阅读
min(arg1, arg2, *args[, key])
If one positional argument is provided, it should be an iterable. The smallest item in the iterable is returned. If two or more positional arguments are provided, the smallest of the positional arguments is returned.
There are two optional keyword-only arguments. The key argument specifies a one-argument ordering function like that used for list.sort(). The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a ValueError is raised.
If multiple items are minimal, the function returns the first one encountered. This is consistent with other sort-stability preserving tools such as sorted(iterable, key=keyfunc)[0] and heapq.nsmallest(1, iterable, key=keyfunc).
New in version 3.4: The default keyword-only argument.
Manual
直译
实例
拓展阅读
参数形式
min(iterable, *[, key, default])min(arg1, arg2, *args[, key])
Manual
Return the smallest item in an iterable or the smallest of two or more arguments.If one positional argument is provided, it should be an iterable. The smallest item in the iterable is returned. If two or more positional arguments are provided, the smallest of the positional arguments is returned.
There are two optional keyword-only arguments. The key argument specifies a one-argument ordering function like that used for list.sort(). The default argument specifies an object to return if the provided iterable is empty. If the iterable is empty and default is not provided, a ValueError is raised.
If multiple items are minimal, the function returns the first one encountered. This is consistent with other sort-stability preserving tools such as sorted(iterable, key=keyfunc)[0] and heapq.nsmallest(1, iterable, key=keyfunc).
New in version 3.4: The default keyword-only argument.
直译
除返回值为最小值外,其他具体内容与max()相同。实例
>>> a = [2, 5, 6, 9] >>> min(a) 2 >>> max(i for i in range(10)) 0 >>> b = [] >>> min(b) Traceback (most recent call last): File "<pyshell#36>", line 1, in <module> min(b) ValueError: min() arg is an empty sequence >>> min(b, [1]) [1] >>> min('CSDN') 'C'
拓展阅读
max()相关文章推荐
- Python 内建函数 - max(iterable, *[key, default])
- Python 内建函数 - next(iterable[, default])
- python四个带 key 参数的函数(max、min、map、filter)
- Python标准库:内置函数max(iterable, *[, key, default])
- Python标准库:内置函数max(iterable, *[, key, default])
- Python标准库:内置函数min(iterable, *[, key, default])
- Python标准库:内置函数min(iterable, *[, key, default])
- Python内置函数min(iterable, *[, key, default])
- Python标准库:内置函数max(iterable, *[, key, default])
- Python标准库:内置函数set([iterable])
- Python 读Dict数据的方法,解决key 不在dict的问题,get()函数,setdefault()函数
- Python 内建函数 - set([iterable])
- python比较函数min
- python min() 函数
- Python 内建函数 - list([iterable])
- python函数回顾:min()
- Python标准库:内置函数sorted(iterable[, key][, reverse])
- Python标准库:内置函数set([iterable])
- Python 内建函数 - map(function, iterable, ...)
- Python标准库:内置函数set([iterable])