pyhton的any() 函数:
判断给定的可迭代参数 iterable :
全部为 False,返回 False; 至少有一个为 True,则返回 True.
元素除了是 0、空、FALSE 外都算 TRUE。
any() 方法的语法:
any(iterable)
示例:(参考:http://www.runoob.com/python/python-func-any.html)
>>>any(['a', 'b', 'c', 'd']) # 列表list,元素都不为空或0 True >>> any(['a', 'b', '', 'd']) # 列表list,存在一个为空的元素 True >>> any([0, '', False]) # 列表list,元素全为0,'',false False >>> any(('a', 'b', 'c', 'd')) # 元组tuple,元素都不为空或0 True >>> any(('a', 'b', '', 'd')) # 元组tuple,存在一个为空的元素 True >>> any((0, '', False)) # 元组tuple,元素全为0,'',false False >>> any([]) # 空列表 False >>> any(()) # 空元组 False