Logical operation between two Boolean lists

前端 未结 7 809
终归单人心
终归单人心 2021-02-07 15:42

I get a weird result and I try to apply the and or the or operator to 2 Boolean lists in python. I actually get the exact opposite of what I was expec

7条回答
  •  误落风尘
    2021-02-07 16:11

    Very convenient way:

    >>> import numpy as np
    >>> np.logical_and([True, False, False], [True, True, False])
    array([ True, False, False], dtype=bool)
    >>> np.logical_or([True, False, False], [True, True, False])
    array([ True,  True, False], dtype=bool)
    

提交回复
热议问题