What\'s the correct way to convert bytes to a hex string in Python 3?
I see claims of a bytes.hex method, bytes.decode codecs, and have tri
bytes.hex
bytes.decode
Since Python 3.5 this is finally no longer awkward:
>>> b'\xde\xad\xbe\xef'.hex() 'deadbeef'
and reverse:
>>> bytes.fromhex('deadbeef') b'\xde\xad\xbe\xef'
works also with the mutable bytearray type.
bytearray
Reference: https://docs.python.org/3/library/stdtypes.html#bytes.hex