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' 
    就可以解决了
  • 相关阅读:
    vmware导出为ovf
    华三接入交换机推荐
    mysql root情况
    ospf精确宣告地址
    kubernetes k8s yum localinstall
    js判断邮箱、用户名、手机号码和电话号码是否输入正确?
    如何修改Oracle中表的字段长度?
    mybatis与hibernate区别
    SSM框架的优势?
    SSH框架的优势?
  • 原文地址:https://www.cnblogs.com/iBoundary/p/13302270.html
Copyright © 2011-2022 走看看