[转] **Python错误记录:' pymysql KeyError:255'**

Traceback (most recent call last): ... File "C:\Program Files\Python36\lib\site-packages\pymysql\__init__.py", line 90, in Connect return Connection(*args, **kwargs) File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 706, in __init__ self.connect() File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 931, in connect self._get_server_information() File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 1269, in _get_server_information self.server_charset = charset_by_id(lang).name File "C:\Program Files\Python36\lib\site-packages\pymysql\charset.py", line 38, in by_id return self._by_id[id] KeyError: 255

主要原因是MySQL8.0更新了很多字符集,但是这些字符集长度超过255了,所以旧版的PyMySQL不支持长度超过255的字符
解决方法, 更新PyMySQL:

pip install --upgrade PyMySQL

上一篇:super()调用父类方法使用python


下一篇:super关键字