用AI赚第一桶💰低成本搭建一套AI赚钱工具,源码可二开。 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](concrete.xhtml "具体的对象层") | - [上一页](buffer.xhtml "缓冲协议") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python/C API 参考手册](index.xhtml) » - [抽象对象层](abstract.xhtml) » - $('.inline-search').show(0); | # Old Buffer Protocol 3\.0 版后已移除. These functions were part of the "old buffer protocol" API in Python 2. In Python 3, this protocol doesn't exist anymore but the functions are still exposed to ease porting 2.x code. They act as a compatibility wrapper around the [new buffer protocol](buffer.xhtml#bufferobjects), but they don't give you control over the lifetime of the resources acquired when a buffer is exported. Therefore, it is recommended that you call [`PyObject_GetBuffer()`](buffer.xhtml#c.PyObject_GetBuffer "PyObject_GetBuffer")(or the `y*` or `w*` [format codes](arg.xhtml#arg-parsing) with the [`PyArg_ParseTuple()`](arg.xhtml#c.PyArg_ParseTuple "PyArg_ParseTuple") family of functions) to get a buffer view over an object, and [`PyBuffer_Release()`](buffer.xhtml#c.PyBuffer_Release "PyBuffer_Release") when the buffer view can be released. int `PyObject_AsCharBuffer`([PyObject](structures.xhtml#c.PyObject "PyObject") *\*obj*, const char *\*\*buffer*, Py\_ssize\_t *\*buffer\_len*)Returns a pointer to a read-only memory location usable as character-based input. The *obj* argument must support the single-segment character buffer interface. On success, returns `0`, sets *buffer* to the memory location and *buffer\_len* to the buffer length. Returns `-1` and sets a [`TypeError`](../library/exceptions.xhtml#TypeError "TypeError") on error. int `PyObject_AsReadBuffer`([PyObject](structures.xhtml#c.PyObject "PyObject") *\*obj*, const void *\*\*buffer*, Py\_ssize\_t *\*buffer\_len*)Returns a pointer to a read-only memory location containing arbitrary data. The *obj* argument must support the single-segment readable buffer interface. On success, returns `0`, sets *buffer* to the memory location and *buffer\_len* to the buffer length. Returns `-1` and sets a [`TypeError`](../library/exceptions.xhtml#TypeError "TypeError") on error. int `PyObject_CheckReadBuffer`([PyObject](structures.xhtml#c.PyObject "PyObject") *\*o*)Returns `1` if *o* supports the single-segment readable buffer interface. Otherwise returns `0`. This function always succeeds. Note that this function tries to get and release a buffer, and exceptions which occur while calling corresponding functions will get suppressed. To get error reporting use [`PyObject_GetBuffer()`](buffer.xhtml#c.PyObject_GetBuffer "PyObject_GetBuffer") instead. int `PyObject_AsWriteBuffer`([PyObject](structures.xhtml#c.PyObject "PyObject") *\*obj*, void *\*\*buffer*, Py\_ssize\_t *\*buffer\_len*)Returns a pointer to a writable memory location. The *obj* argument must support the single-segment, character buffer interface. On success, returns `0`, sets *buffer* to the memory location and *buffer\_len* to the buffer length. Returns `-1` and sets a [`TypeError`](../library/exceptions.xhtml#TypeError "TypeError") on error. ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](concrete.xhtml "具体的对象层") | - [上一页](buffer.xhtml "缓冲协议") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python/C API 参考手册](index.xhtml) » - [抽象对象层](abstract.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。