我想在Python 3中从NumPy数组中获取一个缓冲区。
我找到了以下代码:
$ python3
Python 3.2.3 (default, Sep 25 2013, 18:25:56)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> a = numpy.arange(10)
>>> numpy.getbuffer(a)
然而,在最后一步时它会产生错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getbuffer'
为什么我的操作不正确? 该代码在Python 2中运行良好。 我使用的numpy版本是1.6.1。