码迷,mamicode.com
首页 > 编程语言 > 详细

python的min()函数也可用于比较tuple

时间:2014-10-19 00:01:09      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   os   ar   for   sp   

 

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(arg1arg2*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.

python的min()函数也可用于比较tuple

标签:des   style   blog   color   io   os   ar   for   sp   

原文地址:http://www.cnblogs.com/lvye-song/p/4033895.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!