不可轻言放弃,否则对不起自己!

python all any

上一篇 / 下一篇  2014-07-07 14:53:15 / 个人分类:python

python all any

all
def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

any
def any(iterable):
   for element in iterable:
       if  element:
           return False
   return True
   

all 只要list或tupe中含有0,'',false中的任何一个,则为false;否则为true
any 只要list或tupe中含有0,'',false(全部),则为false;否则为true
注意:
all  空元组、空列表返回true
any  空元组、空列表返回false

TAG:

引用 删除 350919042   /   2014-07-08 18:35:33
3
 

评分:0

我来说两句

Open Toolbar