I just installed Anaconda to a Windows 10 machine (Python 2.7.12 |Anaconda 4.2.0 (64-bit)|) I am having an issue reading text from a file. Please see code and output below. I want the actual text from the file.
Thanks!!
Output:
['\xff\xfeT\x00h\x00i\x00s\x00',
'\x00i\x00s\x00',
'\x00a\x00',
'\x00t\x00e\x00s\x00t\x00.\x00',
'\x00',
'\x00',
'\x00',
'\x00T\x00h\x00i\x00s\x00',
'\x00i\x00s\x00',
'\x00a\x00',
'\x00t\x00e\x00s\x00t\x00']
Code:
try:
with open('test.txt', 'r') as f:
text = f.read()
except Exception as e:
print e
print text.split()
test.txt:
This is a test.
This is a test