Reputation: 31
I used to be able to perform file io operations on plain text files using python 3, however a few days ago I encountered errors whenever I tried to use the readlines()
method on plain text files.
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
I get this above error message whenever I try to use the readlines()
method, previously it worked as it was supposed to.
Upvotes: 2
Views: 739
Reputation: 51
Are you specifying the encoding when opening the file?
with open('file', 'r', encoding='utf-8') as f:
...
Upvotes: 1