如何使用“和”运算符将列表中的每个项目加入

时间:2019-07-11 23:41:25

标签: python list

我需要选择列表中的每个项目,然后在每个项目之间放置逻辑运算符

例如

说我是否有清单:

<table>
  <tr>
    <td>Cell 1</td>
    <td>Cell 2</td>
    <td>Cell 3</td>
    <td>Cell 4</td>
  <tr>
</table>

我想要:

if(prevProps.active !== this.props.active && this.props.active !== null) {

2 个答案:

答案 0 :(得分:1)

from operator import and_
from functools import reduce
reduce(and_, ['a' , 'b' , 'c'], True)

是的,这不适用于字符

答案 1 :(得分:0)

all函数不是您要尝试的功能吗?

a = ['a','b','c']
all(a)