我想比较numpy数组与列表.... 因为我是新来的python,我不知道numpy数组 我想知道numpy数组的应用 请帮助理解numpy数组。numpy模块阵列与列表比较
>>> from numpy import *
>>> res1 = []
>>> res2 = array([])
>>> if res1 == res2:
... print 'hi'
... else:
... print 'bye'
...
bye
>>> res1 = [1]
>>> res2 = array([1])
>>> if res1 == res2:
... print 'hi'
... else:
... print 'bye'
...
hi
>>> res1 = [1,2]
>>> res2 = array([1, 2])
>>> if res1 == res2:
... print 'hi'
... else:
... print 'bye'
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
中的任何一个,请帮助为什么我收到值误差
谢谢你,它帮了我很多 – shrum 2014-09-02 12:37:50