Sometimes the AND function in python
is used when operating on the array in . Here is a record:: Return when the iterable object is empty . Or when iterables whether all values are all values are then returned . Otherwise, it returns . : Return when the iterable object is empty . Or when there is a value for the iterable object , if it exists, return , otherwise return . code show as below:python
all()
any()
all()
True
True
True
True
False
any()
False
True
True
False
import numpy as np
class Debug:
@staticmethod
def pythonFunction():
x = np.array([0, 1, 2])
print(x.all())
print(x.any())
if __name__ == '__main__':
debug = Debug()
debug.pythonFunction()
"""
False
True
"""
We can see that there is a 0
value in the array, which is equivalent to False
, so .all()
it returns False
when used .any()
, and returns when used True
. If the array is empty, skip here, you can try it yourself.
The code word is not easy, if you find it useful, please raise your hand to give a like and let me recommend it for more people to see~