|
代码如下:
#打开数据库连接,参数1、主机名,2、用户名,3、密码 4、数据库名称
db = pymysql.connect("localhost","root","123456","my_user",charset="utf8")
#创建游标对象
cursor = db.cursor()
#使用execute() 方法执行SQL查询
cursor.execute("SELECT * from msa_user")
#使用fetchone获取单条数据
data = cursor.fetchall()
print (data)
db.close()
打印结果:((1, u'\u674e\u590f\u9686', u'\u7535\u8111'), (2, u'\u5f20\u4e09', u'\u7535\u5f71'), (5, u'foo', u'bar'))
问题:如果将打印结果中文显示?
|
|