I'm tring to write equivalent for encode("hex")
in python3.
Here what i got:
s = "'"
print(str(s).encode('hex'))
>>27
Tring binascii
in Python 2.7
:
import binascii
s = "'"
print(binascii.hexlify(str(s)))
>>27
So in Python 2.7
both methods give same result. Now i tring to run this code in Python 3.5
:
import binascii
s = "'"
print(binascii.hexlify(str(s)))
>>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
After i tried:
import binascii
s = "'"
print(binascii.hexlify(str(s).encode('utf8')))
>>b'27'
But not sure what i have to do next. How to get my 27
?