我想比較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