#coding:utf8
import MySQLdb
db = MySQLdb.connect(host="192.168.0.150", port=3307, user="root", passwd="123456", db="db_wbs",charset='utf8')
# db = MySQLdb.connect("localhost","root","admin","test")
cursor = db.cursor()
cursor.execute("select * from sys_users ")
data = cursor.fetchone()
print(data)
最重要的是加一个:charset='utf8' 则不会显示乱码
转载于:https://www.cnblogs.com/dxa304814183/p/7877522.html