这个极为简单的numpy脚本有什么问题?

10

我在Python 2.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, in <module>
    numpy.savetext('foo.txt', a)
AttributeError: 'module' object has no attribute 'savetext'

有什么问题吗?

1个回答

21

这是numpy.savetxt,但没有e


谢谢!我知道这一定是某些非常愚蠢的东西。 - user3268289
如果你安装了IPython,你将会在交互式提示符中获得TAB自动补全功能。这样你就可以输入numpy.[TAB]并查看所有可用的函数。它可以避免你犯这种错误。 - unutbu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接