I have an utf-8 encoded file that contains multiple lines like
\x02I don't like \x0307bananas\x03.\x02
Hey, how are you doing?
with codecs.open(file, 'r', encoding='utf-8') as q:
quotes = q.readlines()
\x02I don't like \x0307bananas\x03\x02
According to this answer, changing the following should have the expected result.
In Python 3:
codecs.open(file, 'r', encoding='utf-8')
codecs.open(file, 'r', encoding='unicode_escape')
In Python 2:
codecs.open(file, 'r', encoding='string_escape')