I have this file, testpi.txt, which i'd like to convert into a list of sentences.
>>>cat testpi.txt
This is math π.
That is moth pie.
Here's what I've done:
r = open('testpi.txt', 'r')
sentence_List = r.readlines()
print sentence_List
And, when the output is sent to another text file - output.txt
, this is how it looks like in output.txt
:
['This is math \xcf\x80. That is moth pie.\n']
I tried codecs too, r = codecs.open('testpi.txt', 'r',encoding='utf-8')
,
but the output then consists of a leading 'u' in all the entries.
How could I display this byte string - \xcf\x80
as π
, in the output.txt
Please guide me, thanks.