chararray.tobytes(order='C')¶Construct Python bytes containing the raw data bytes in the array.
Constructs Python bytes showing a copy of the raw contents ofdata memory. The bytes object can be produced in either ‘C’ or ‘Fortran’,or ‘Any’ order (the default is ‘C’-order). ‘Any’ order means C-orderunless the F_CONTIGUOUS flag in the array is set, in which case itmeans ‘Fortran’ order.
New in version 1.9.0.
| Parameters: | order : {‘C’, ‘F’, None}, optional
|
|---|---|
| Returns: | s : bytes
|
Examples
>>>x=np.array([[0,1],[2,3]])>>>x.tobytes()b'\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00'>>>x.tobytes('C')==x.tobytes()True>>>x.tobytes('F')b'\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00'