python 通过 MySQLdb 链接mysql
mysql使用的是 utf8编码,出现乱码。
解决方法:
conn = MySQLdb.connect (host = "localhost", user = "root", passwd = "", db = "aaa", charset="utf8") db = MySQLdb.connect(host=DB_HOST, user=DB_USER, passwd=DB_PASS, db=DB_NAME, charset="utf8", use_unicode=True)
http://stackoverflow.com/questions/9154998/python-encoding-mysql