UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x80 in position 540: illegal multibyte sequence

错误:Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.
Failed calling sys.interactivehook
Traceback (most recent call last):
File “F:\Anaconda3\lib\site.py”, line 439, in register_readline
readline.read_history_file(history)
File “F:\Anaconda3\lib\site-packages\pyreadline\rlmain.py”, line 165, in read_history_file
self.mode._history.read_history_file(filename)
File “F:\Anaconda3\lib\site-packages\pyreadline\lineeditor\history.py”, line 82, in read_history_file
for line in open(filename, ‘r’):
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xaf in position 173: illegal multibyte sequence
解决方法:D:\Anaconda3\Lib\site-packages\pyreadline\lineeditor\history.py 第82行:
将:for line in open(filename, ‘r’)
改为:for line in open(filename, ‘rb’)
改后保存即可

上一篇:文件名通配符、命令别名


下一篇:A Child's History of England.234