【发布时间】:2011-07-08 18:29:37
【问题描述】:
我想比较两个 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 arrays comparison numpy