typeerror: a bytes-like object is required, not 'str'
In the above code, the “ TypeError: a bytes-like object is required, not 'str' ” is thrown at the last line when executed in Python 3. In the line, “ with open ('myfile.txt', 'rb') as f ”, the file is opened in binary mode. So the entire text is returned in the form of bytes and not strings. So, in the line “ if 'some-pattern' in line ...