您好,欢迎访问一九零五行业门户网

python mysql数据库 'latin

unicodeencodeerror:'latin-1' codec can't encode character ... this is because mysqldb normally tries to encode everythin to latin-1. this can be fixed by executing the following commands right after you've etablished the connection: db . s
unicodeencodeerror:'latin-1' codec can't encode character ...
this is because mysqldb normally tries to encode everythin to latin-1. this can be fixed by executing the following commands right after you've etablished the connection:
db.set_character_set('utf8')dbc.execute('set names utf8;') dbc.execute('set character set utf8;')dbc.execute('set character_set_connection=utf8;')
db is the result of mysqldb.connect, and dbc is the result of db.cursor().
意思就是mysqldb正常情况下会尝试将所有的内容转为latin1字符集处理
其它类似信息

推荐信息