2014-05-13 137 views
2

我運行在Python 2.7這個非常簡單的numpy腳本有什麼問題?

import numpy 
a = numpy.ndarray(shape=(2,2), dtype=float, order='F') 
print numpy.mean(a) 
numpy.savetext('foo.txt', a) 

以下,並得到這樣的結果

[[email protected] bar]$ python f.py 
8.79658981512e-317 
Traceback (most recent call last): 
    File "f.py", line 4, in <module> 
    numpy.savetext('foo.txt', a) 
AttributeError: 'module' object has no attribute 'savetext' 

有什麼不對?

回答

8

這是numpy.savetxt,沒有e

+0

謝謝!知道它必須是非常愚蠢的東西。 – user3268289

+0

如果您安裝[IPython](http://ipython.org/),您將在交互式提示符處獲得TAB完成。所以你可以鍵入'numpy。[TAB]'並查看所有可用的功能。它可以幫助你避免這種錯誤。 – unutbu