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' 
    就可以解决了
  • 相关阅读:
    云计算、大数据和人工智能简单概述
    Linux 文件管理命令语法、参数、实例全汇总(一)
    C#之继承
    类和结构(二)
    类和结构(一)
    C#基础语法(二)
    C#基础语法(一)
    dotnet体系结构
    九卷读书:刘润商学院学习笔记1
    Linux内存管理
  • 原文地址:https://www.cnblogs.com/iBoundary/p/13302270.html
Copyright © 2011-2022 走看看