A reverse conversion function exists to transform a bytes object into its
hexadecimal representation.
- .. method:: hex()
+ .. method:: hex([sep[, bytes_per_sep]])
Return a string object containing two hexadecimal digits for each
byte in the instance.
A reverse conversion function exists to transform a bytearray object into its
hexadecimal representation.
- .. method:: hex()
+ .. method:: hex([sep[, bytes_per_sep]])
Return a string object containing two hexadecimal digits for each
byte in the instance.
.. versionadded:: 3.5
+ .. versionchanged:: 3.8
+ Similar to :meth:`bytes.hex`, :meth:`bytearray.hex` now supports
+ optional *sep* and *bytes_per_sep* parameters to insert separators
+ between bytes in the hex output.
+
Since bytearray objects are sequences of integers (akin to a list), for a
bytearray object *b*, ``b[0]`` will be an integer, while ``b[0:1]`` will be
a bytearray object of length 1. (This contrasts with text strings, where
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'*.
- .. method:: hex()
+ .. method:: hex([sep[, bytes_per_sep]])
Return a string object containing two hexadecimal digits for each
byte in the buffer. ::
.. versionadded:: 3.5
+ .. versionchanged:: 3.8
+ Similar to :meth:`bytes.hex`, :meth:`memoryview.hex` now supports
+ optional *sep* and *bytes_per_sep* parameters to insert separators
+ between bytes in the hex output.
+
.. method:: tolist()
Return the data in the buffer as a list of elements. ::