在我的 python3 程序中从 MySQL 打印西里尔文本时,我得到的是问号而不是文本。
我在 MySQL 表中看到的文本是 Рожден ден
。
我在 python3 程序中看到的文本是 ?????? ???
.
行的类型是 str 类。
对于这个列表,我使用的是 wxpython、wx 模块。
conn = pymysql.connect(host='localhost', database='Tasks', password='password', user='user')
cursor = conn.cursor()
cursor.execute('SELECT occasion,date,event FROM Important_Days')
records = cursor.fetchall()
for row in records:
pos = self.list1.InsertStringItem(0, row[0])
self.list1.SetStringItem(pos, 1, str(row[1]))
self.list1.SetStringItem(pos, 2, row[2])
conn.close()
最佳答案
问号是在INSERT
期间创建的,无法从中取出西里尔字母。
参见 Trouble with UTF-8 characters; what I see is not what I stored 中的“问号”
有关 Python 的注释请参阅此:http://mysql.rjweb.org/doc.php/charcoll#python
关于python - 如何将问号而不是文本转换为西里尔字母?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55879469/