Based on John Clement's answer, try the python3.7 codes. I have this error:
>>> s = '1234'
>>> hexlify(s)
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
hexlify(s)
TypeError: a bytes-like object is required, not 'str'
It is solved by the following codes:
>>> str = '1234'.encode()
>>> hexlify(str).decode()
'31323334'
source
share