#转载链接 https://blog.csdn.net/JNingWei/article/details/78651535
np.logical_and (逻辑与)
Syntax
np.logical_and(x1, x2, *args, **kwargs)
Test
>>> np.logical_and(True, False)
False
>>> np.logical_and([True, False], [False, False])
array([False, False], dtype=bool)
>>> x = np.arange(5)
>>> np.logical_and(x>1, x<4)
array([False, False, True, True, False], dtype=bool)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
np.logical_or (逻辑或)
Syntax
np.logical_or(x1, x2, *args, **kwargs)
Test
>>> np.logical_or(True, False)
True
>>> np.logical_or([True, False], [False, False])
array([ True, False], dtype=bool)
>>> x = np.arange(5)
>>> np.logical_or(x < 1, x > 3)
array([ True, False, False, False, True], dtype=bool)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
np.logical_not (逻辑非)
Syntax
logical_not(x, *args, **kwargs)
Test
>>> np.logical_not(3)
False
>>> np.logical_not([True, False, 0, 1])
array([False, True, True, False], dtype=bool)
>>> x = np.arange(5)
>>> np.logical_not(x<3)
array([False, False, False, True, True], dtype=bool)
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8