尝试从mysql (charset:utf8 8)表中查询所有项,该表的字段包含带有中文和其他特殊字符的行,我将接受上述错误。
items = session.query(Item).all()文件"/root/.local/share/virtualenvs/server-WesSANjA/lib/python3.8/site-packages/MySQLdb/cursors.py",第355行,在_post_get_result self._rows = self._fetch_row(0) File "/root/.local/share/virtualenvs/server-WesSANjA/lib/python3.8/site-packages/MySQLdb/cursors.py",第328行中,在_fetch_row返回self._result.fetch_row(大小,文件"/usr/local/lib/python3.8/encodings/cp1252.py",( self._fetch_type)第15行,在解码中返回codecs.charmap_decode(输入、错误、decoding_table) UnicodeDecodeError:“charmap”编解码器无法解码位置为30的字节0x9d :字符映射到
发布于 2020-09-03 15:59:02
正如文档这里中所描述的那样,我们需要使用?charset=utf8mb4来实现完全的Unicode支持(包括表情符号):
e = create_engine(
"mysql+pymysql://scott:tiger@localhost/test?charset=utf8mb4")https://stackoverflow.com/questions/63719999
复制相似问题