Python 这个极其简单的numpy脚本有什么问题?
我在Python2.7中运行了以下内容Python 这个极其简单的numpy脚本有什么问题?,python,numpy,Python,Numpy,我在Python2.7中运行了以下内容 import numpy a = numpy.ndarray(shape=(2,2), dtype=float, order='F') print numpy.mean(a) numpy.savetext('foo.txt', a) 然后得到这个结果 [me@foo bar]$ python f.py 8.79658981512e-317 Traceback (most recent call last): File "f.py", line 4,
import numpy
a = numpy.ndarray(shape=(2,2), dtype=float, order='F')
print numpy.mean(a)
numpy.savetext('foo.txt', a)
然后得到这个结果
[me@foo 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'
[me@foobar]$python f.py
8.79658981512e-317
回溯(最近一次呼叫最后一次):
文件“f.py”,第4行,在
savetext('foo.txt',a)
AttributeError:“模块”对象没有属性“保存文本”
怎么了?是
numpy.savetxt
,没有e
谢谢!我知道这一定很愚蠢。如果你安装了,你会在交互提示下完成标签。因此,您可以键入numpy.[TAB]
并查看所有可用函数。它可以帮你避免这种错误。