执行pymysql.connect时出现错误Keyerror 255
这是代码
import pymysqlpymysql.connect(
host='localhost',
port=3306,
user='root',
password='iDontWannaSay',
db='iDontWannaShow',
charset='utf8'
)
错误回溯为:
data is :::::b'\xff\x02\x00\xff\x81\x15'....##### I was add near line 1279 which is print("data is :::::%s...."%data[i:i+6])Traceback (most recent call last):
File "C:\Users\123\Desktop\pymysqldebug.py", line 8, in <module>
charset='utf8'
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\__init__.py", line 90, in Connect
return Connection(*args, **kwargs)
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 709, in __init__
self.connect()
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 934, in connect
self._get_server_information()
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\connections.py", line 1279, in _get_server_information
self.server_charset = charset_by_id(lang).name
File "D:\Program Files (x86)\Python\Python35\lib\site-packages\pymysql\charset.py", line 39, in by_id
return self._by_id[id]
KeyError: 255
似乎struct.unpack方法将’\ xff '解析为255并分配给self.server_language
,无论传递的非null字符集参数如何。
这是MySQL版本问题吗?(版本8.0.1-dmr
)
回答:
可以参考 拉取请求591
以上是 执行pymysql.connect时出现错误Keyerror 255 的全部内容, 来源链接: utcz.com/qa/424074.html