I\'ve very recently migrated to Py 3.5. This code was working properly in Python 2.7:
with open(fname, \'rb\') as f:
lines = [x.strip() for x in f.readli
You opened the file in binary mode:
The following code will throw a TypeError: a bytes-like object is required, not 'str'.
for line in lines:
print(type(line))#
if 'substring' in line:
print('success')
The following code will work - you have to use the decode() function:
for line in lines:
line = line.decode()
print(type(line))#
if 'substring' in line:
print('success')