Python 3.1.1 string to hex February 13, 2023 by Tarik The hex codec has been chucked in 3.x. Use binascii instead: >>> binascii.hexlify(b'hello') b'68656c6c6f'