lineeditor\history.py line 82, in read_history_file UnicodeDecodeError: ‘gbk‘ codec can‘t decode by

E:\Python\Python36\lib\site-packages\pyreadline\lineeditor\history.py line 82, in read_history_file
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xb3 in position 3887: illegal multibyte sequence
最近打开python总会提示以上,编码错误啦!
一直没管!
那打开history.py瞧一瞧

  def read_history_file(self, filename=None): 
        '''Load a readline history file.'''
        if filename is None:
            filename = self.history_filename
        try:
            for line in open(filename, 'r'):
                self.add_history(lineobj.ReadLineTextBuffer(ensure_unicode(line.rstrip())))
        except IOError:
            self.history = []
            self.history_cursor = 0

再看

class LineHistory(object):
    def __init__(self):
        self.history = []
        self._history_length = 100
        self._history_cursor = 0
        self.history_filename = os.path.expanduser(ensure_str('~/.history')) #Cannot expand unicode strings correctly on python2.4
        self.lastcommand = None
        self.query = ""
        self.last_search_for = ""

所以是.history文件中有中文了,删掉就行了。
python最大的优点就是你不明白的地方,即使第三方包,可以点进去自己去修改它的代码然后调试输出,看Java的jar是能随随便便改的吗…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值