return f.read() File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/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 0x8b in position 0: invalid start byte
Как решать эту проблему?
Сам код функции:
def load_data(filepath): if not os.path.exists(filepath): return None with open(filepath, 'r') as f: return f.read()
P.S. В текстовом файле фрагмент из Войны и Мира