PyDocs

Nav

Python Runtime Services

memoryview.tobytes

builtins

method of memoryview · Added in 3.8
  • memoryview.tobytes(order='C')
Return the data in the buffer as a byte string.

Order can be {'C', 'F', 'A'}.  When order is 'C' or 'F', the data of
the original array is converted to C or Fortran order.  For
contiguous views, 'A' returns an exact copy of the physical memory.
In particular, in-memory Fortran order is preserved.  For
non-contiguous views, the data is converted to C first.  order=None
is the same as order='C'.
1 Example
>>> m = memoryview(b"abc")
>>> m.tobytes()
b'abc'
>>> bytes(m)
b'abc'
from the Python docs
See Also
No see-alsos for builtins/memoryview.tobytes
0 Notes
No notes for memoryview.tobytes