ID EN
IO

getbuffer

Python 3.11

Return a readable and writable view over the contents of the buffer without copying them. Also, mutating the view will transparently update the contents of the buffer:

Syntax

PYTHON
getbuffer()

Examples

Example 1
PYTHON
>>> b = io.BytesIO(b"abcdef")
>>> view = b.getbuffer()
>>> view[2:4] = b"56"
>>> b.getvalue()
b'ab56ef'

See Also

BytesIO