我希望比较两个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。
!=
来说使用.any
更合适,而对于==
来说使用.all
更合理。 - SiggyF