【发布时间】:2014-03-16 06:35:37
【问题描述】:
我想从 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。
【问题讨论】:
标签: python python-3.x numpy