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
Use the binascii module:
binascii
>>> import binascii >>> binascii.hexlify('foo'.encode('utf8')) b'666f6f' >>> binascii.unhexlify(_).decode('utf8') 'foo'
See this answer: Python 3.1.1 string to hex