i'm working to a personal project and i'm confronting a error: TypeError: a bytes-like object is required, not 'str'
Here is my code: CLICK TO SEE THE CODE
I want to make this script that is trying to find into the file a input text. Thanks!
TypeError implies that there is a mismatch in the datatype required vs given data's type. The function requires input of type 'bytes' while the code inputs data of type 'str'.
To convert the input string into byte-like object use str.encode function.
>>> string = "abcdef"
>>> type(string)
<class 'str'>
>>> string = string.encode('ascii')
>>> type(string)
<class 'bytes'>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With