Logical operation between two Boolean lists

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

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:15

    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)
    

提交回复
热议问题