I am trying to hexlify
input from user but I get the following error:
TypeError: a bytes-like object is required, not 'str'
If I use b
before string then it works but how can I do it with input?
Here is the code:
import binascii as bs
text = input('Please Enter Your text:')
bs.hexlify(text)
I tried doing:
text = input('Please enter you text:')
import binascii as bs
bs.hexlify(bytes(text))
But it gives the following error:
TypeError: string argument without an encoding
How can I do that?
Add encoding parameter to bytes
:
import binascii as bs
text = input('Please Enter Your text:')
bs.hexlify(bytes(text, encoding="utf8"))