I have very recently switched to the Py 3.5 version but I noticed that the code mentioned below was working properly in Python 2.7:
with open(fname, 'rb') as f:
lines = [x.strip() for x in f.readlines()]
for line in lines:
tmp = line.strip().lower()
if 'some-pattern' in tmp: continue
# ... code
After switching to 3.5, I'm getting the following ERROR:-
TypeError: a bytes-like object is required, not 'str'
error on the last line (the pattern search code).
I have tried to use the .decode() function on either side of the statement along with the line mentioned below:
if tmp.find('some-pattern') != -1: continue
- to no avail.
I was able to resolve almost all 2:3 issues quickly, but this little statement is bugging me. Any solution for a way forward beyond this step?