python的min()函数也可用于比较tuple
python的min()函数也可用于比较tuple
>>> a = (2,'asv','dfg') >>> b = (3,'gsg','weg') >>> c = (5,'bad','ser') >>> min(a, b, c) (2, 'asv', 'dfg') >>>
这是官方文档
min(iterable[, key])min(arg1, arg2, *args[, key])
Return the smallest item in an iterable or the smallest of two or more arguments.
If one positional argument is provided, iterable must be a non-empty iterable (such as a non-empty string, tuple or list). The smallest item in the iterable is returned. If two or more positional arguments are provided, the smallest of the positional arguments is returned.
The optional key argument specifies a one-argument ordering function like that used for list.sort(). The key argument, if supplied, must be in keyword form (for example, min(a,b,c,key=func)).
Changed in version 2.5: Added support for the optional key argument.