通过Python在我的mySQL数据库中添加了大约6k行后,有些字母是错误的(波兰字母),比如Åforł和żfor zb等。我该如何修复它?我的python代码是:
# -*- coding: utf-8 -*-
import MySQLdb
import string
import codecs
file = codecs.open("----", r , utf-8 )
db = MySQLdb.connect(host="-----", port=3306, user="-----", passwd="------", db="----")
cursor = db.cursor()
for line in file:
lines = string.replace(line, " ", " )
cursor.execute("INSERT INTO Logs (Text) VALUE ( %s )"% lines.encode("utf-8"))
db.close()
print("done")
and after running this code, it works normally , but in PhpMyAdmin, there is wrong letters. Coding in Database is UTF-8, file is in ANSI as UTF-8 (from notepad++). Any Help?