【mysql】编码问题
时间:2017-06-23 17:47:50
收藏:0
阅读:306
原始数据是unicode,存入数据库。需要注意的几个地方:
1、建立数据库时,选择编码方式为utf8 -- UTF-8 Unicode
2、代码中建立数据库连接时,选择charset=utf8
3、存入数据前,处理数据MySQLdb.escape_string(data.encode(‘utf-8‘)) 先编码为utf-8,然后转义字符
原文:http://www.cnblogs.com/dplearning/p/7070883.html
评论(0)