np.logical_and (逻辑与)
import numpy as np
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)
np.logical_or (逻辑或)
p.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)
np.logical_not (逻辑非)
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)