startswith TypeError in function
If remaining to open a file in binary, replacing 'STR' to bytes('STR'.encode('utf-8')) works for me.
It's because you're opening the file in bytes mode, and so you're calling bytes.startswith()
and not str.startswith()
.
You need to do line.startswith(b'>')
, which will make '>'
a bytes literal.