【mysql】编码问题

原始数据是unicode,存入数据库。需要注意的几个地方:

 

1、建立数据库时,选择编码方式为utf8 -- UTF-8 Unicode

2、代码中建立数据库连接时,选择charset=utf8

3、存入数据前,处理数据MySQLdb.escape_string(data.encode('utf-8'))  先编码为utf-8,然后转义字符

posted @ 2017-06-23 17:10  匡子语  阅读(190)  评论(0)    收藏  举报