首页 > 其他 > 详细

UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 341

时间:2020-07-15 00:50:28      阅读:52      评论:0      收藏:0      [点我收藏+]

错误

Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Failed calling sys.__interactivehook__
Traceback (most recent call last):
  File "C:\Users\向成功\AppData\Local\Programs\Python\Python38\lib\site.py", line 440, in register_readline
    readline.read_history_file(history)
  File "C:\Users\向成功\AppData\Local\Programs\Python\Python38\lib\site-packages\pyreadline\rlmain.py", line 165, in read_history_file
    self.mode._history.read_history_file(filename)
  File "C:\Users\向成功\AppData\Local\Programs\Python\Python38\lib\site-packages\pyreadline\lineeditor\history.py", line 82, in read_history_file
    for line in open(filename, r):
UnicodeDecodeError: gbk codec cant decode byte 0xaf in position 341: illegal multibyte sequence

解决办法

进入到该目录:C:\Users\向成功\AppData\Local\Programs\Python\Python38\Lib\site-packages\pyreadline\lineeditor ,
history.py文件的第82行,修改如下:
for line in open(filename, r,encoding=utf-8):
在原有的open函数里 新增了一个参数选项encoding=utf-8 
就可以解决了

 

UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 341

原文:https://www.cnblogs.com/iBoundary/p/13302270.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!