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是能随随便便改的吗…