0

enter image description here

So I'm doing what I always do when I read the file: code:

f= open(filename,'r')
t= f.read().splitlines()
print(t)

but I'm getting a UnicodeDecodeError I don't know why. the error:

Traceback (most recent call last):
  File "try.py", line 21, in <module>
    t= f.read().splitlines()
  File "/Users/jamilaldani/miniconda3/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 307: invalid start byte
Mad Physicist
  • 95,415
  • 23
  • 151
  • 231

1 Answers1

0

As described in a few places on this site, and AndreaConte's comment this is likely to be a file encoded in a different encoding (ie not UTF-8)

This answer may help: https://stackoverflow.com/a/19706723/70131, as may this one if you're willing to lose some data: https://stackoverflow.com/a/12468274/70131

Marcin
  • 1,659
  • 2
  • 15
  • 20