在具有np.ndarray的列表中查找匹配的np.ndarray

2024-06-01 00:06:30 发布

您现在位置:Python中文网/ 问答频道 /正文

新手在这里。。。我有一个给定的np数组(这里是“result”),想检查它是否存在于一个列表中(这里是“codewords”)

 for message in messages: 
    result = message.dot(G) % size_of_alphabet
    if result not in codewords:
        codewords.append(result)

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

我已经尝试了any()的一些组合,但没有任何效果:/


Tags: ofinmessage列表forsizenpany