是否有更简单的方法:
cd = [False,False,True]
ca = [False,False,False]
cp = [False,True,True]
ab[0] = cd[0] or ca[0] or cp[0]
ab[1] = cd[1] or ca[1] or cp[1]
ab[2] = cd[2] or ca[2] or cp[2]
获取[False,True,True]
答案 0 :(得分:8)
ab = [any(x) for x in zip(cd, ca, cp)]
答案 1 :(得分:0)
您可以使用list comprehension:
ab = [cd[x] or ca[x] or cp[x] for x in range(len(cd))]