我想比较两个 1x3 数组,例如:
if output[x][y] != [150,25,75]
(output
这里是 3x3x3 所以 output[x][y]
只是 1x3)。
我收到一条错误消息:
ValueError: The truth value of an array with more than one element is ambiguous.
这是否意味着我需要这样做:
if output[y][x][0] == 150 and output[y][x][1] == 25 and output[y][x][2] == 75:
或者是否有更简洁的方法来做到这一点?
我正在使用 Python v2.6
最佳答案
关于python - 比较python中numpy数组的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6628793/