There is one row in Mysql table as following:
1000, Intel® Rapid Storage Technology
The table's charset='utf8' when was created. When I used python code to read it, it become the following:
Intel® Management Engine Firmware
My python code as following:
db = MySQLdb.connect(db,user,passwd,dbName,port,charset='utf8')
The weird thing was that when I removed the charset='utf8' as following:
db = MySQLdb.connect(db,user,passwd,dbName,port)
, the result become correct.
Why when I indicated charset='utf8' in my code, but got wrong result please?
答案 0 :(得分:0)
Have you tried leaving off the charset in the connect string and then setting afterwards?
db = MySQLdb.connect(db,user,passwd,dbName,port)
db.set_character_set('utf8')
答案 1 :(得分:0)
尝试使用utf8 / utf8mb4时,如果看到 Mojibake ,请检查以下内容。 此讨论也适用于双重编码,这不一定是可见的。
INSERTing
和SELECTing
文字需要指定utf8或utf8mb4时的连接。CHARACTER SET utf8
(或utf8mb4)。<meta charset=UTF-8>
开头。