ID EN
Built-in Types

tobytes

Python 3.11

Return the data in the buffer as a bytestring. This is equivalent to calling the bytes constructor on the memoryview.

Syntax

PYTHON
tobytes(order='C')

Examples

Example 1
PYTHON
>>> m = memoryview(b"abc")
>>> m.tobytes()
b'abc'
>>> bytes(m)
b'abc'

See Also

bytes tobytes() struct