zoukankan      html  css  js  c++  java
  • UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 341

    错误

    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向成功AppDataLocalProgramsPythonPython38libsite.py", line 440, in register_readline
        readline.read_history_file(history)
      File "C:Users向成功AppDataLocalProgramsPythonPython38libsite-packagespyreadline
    lmain.py", line 165, in read_history_file
        self.mode._history.read_history_file(filename)
      File "C:Users向成功AppDataLocalProgramsPythonPython38libsite-packagespyreadlinelineeditorhistory.py", line 82, in read_history_file
        for line in open(filename, 'r'):
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xaf in position 341: illegal multibyte sequence

    解决办法

    进入到该目录:C:Users向成功AppDataLocalProgramsPythonPython38Libsite-packagespyreadlinelineeditor ,
    history.py文件的第82行,修改如下:
    for line in open(filename, 'r',encoding='utf-8'):
    在原有的open函数里 新增了一个参数选项encoding='utf-8' 
    就可以解决了
  • 相关阅读:
    【NOIP2016】换教室
    【NOIP模拟赛】总结
    【Codeforces Round 418】An impassioned circulation of affection DP
    DP测试总结
    【NOIP2012】疫情控制
    【HNOI2016】序列 莫队+单调栈+RMQ
    【Luogu P2709 小B的询问】莫队
    【HNOI2017】影魔
    【HNOI2017】大佬
    阿里云MaxCompute 2019-7月刊
  • 原文地址:https://www.cnblogs.com/iBoundary/p/13302270.html
Copyright © 2011-2022 走看看