|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
大佬们求助啊,mac os python 3.8 jupyter notebook, 我下载下来的record.txt 如果用textedit 打开的话就是图中这样,我run了一遍参考答案的代码,给我这样的error code
请问是我下载的文件问题吗还是我的环境问题?万分感谢!!!
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-40-ab374b26e6a4> in <module>
38 f.close()
39
---> 40 split_file('record.txt')
<ipython-input-40-ab374b26e6a4> in split_file(file_name)
21 f = open(file_name)
22
---> 23 for each_line in f:
24 if each_line[:6] != '======':
25 (role, line_spoken) = each_line.split(':', 1)
~/.pyenv/versions/3.8.2/lib/python3.8/codecs.py in decode(self, input, final)
320 # decode input (taking the buffer into account)
321 data = self.buffer + input
--> 322 (result, consumed) = self._buffer_decode(data, self.errors, final)
323 # keep undecoded input until the next call
324 self.buffer = data[consumed:]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 2: invalid start byte
|
|