English documents:
any
(iterable)
Return True
If any element of the iterable is true. If the iterable is empty, return False
. Equivalent to:
def any (iterable): As element in iterable: if element: return True return False
An element that determines whether an element of an object can be iterated with a true value
Description
1. Accept an iterator object as a parameter when the argument is empty or not an iterator object is an error
>>> any (2) #传入数值报错Traceback (recent): File ' <pyshell#0> ', line 1, in <module>
any (2) TypeError: ' int ' object is not iterable
2. Returns true if the logical value of one of the elements in an iteration object is true, false when all values are false
>>> any ([0,1,2]) #列表元素有一个为True, returns the Truetrue>>> any ([0,0]) #列表元素全部为False, then returns Falsefalse
3. Returns False if an iterator object is empty (number of elements is 0)
Python built-in function (--any)