numpy.logical_and,numpy.logical_or,numpy.logical_not 逻辑与或非 作者:马育民 • 2020-05-26 22:02 • 阅读:10232 # numpy.logical_and 逻辑与 ### 语法 ``` np.logical_and(x1, x2, *args, **kwargs) ``` ### 例子 ``` >>> 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) ``` # numpy.logical_or 逻辑或 ### 语法 ``` np.logical_or(x1, x2, *args, **kwargs) ``` ### 例子 ``` >>> 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) ``` # numpy.logical_not 逻辑非 ### 语法 ``` logical_not(x, *args, **kwargs) ``` ### 例子 ``` >>> 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) ``` 感谢: https://blog.csdn.net/JNingWei/article/details/78651535 原文出处:http://www.malaoshi.top/show_1EF5avR1K5Zn.html