Post
Python
How to resolve the error typeerror a bytes-like object is required not str in python?
here is my code which is throwing an error called a bytes-like object is required not str please help me out
for line in lines:
print(type(line))# <class of 'bytes'>
if 'substring' in line:
print('successful')
Posted on 25th April 2024
You have to use decode() try this
for line in lines:
line = line.decode()
print(type(line))# <class of 'str'>
if 'substring' in line:
print('successful')
STILL GOT QUERIES?