Python Mysql query solve problems Chinese garbled

 Some time ago I wrote a tool a blind hands update zip package to a remote server and sql with Django. But Python Mysql read out from the Chinese characters garbled, as shown below:

Solution: Python specified charset to utf8 connection Mysql, Mysql itself, of course, also need to set the encoding utf8

db = MySQLdb.connect('192.168.1.111', UserName, Password, 'django_admin', charset='utf8')

 

Experience: need more hands-on learning, more thinking in practice.

Guess you like

Origin www.cnblogs.com/xingphimo/p/11136518.html