Python连接MySQL乱码(中文变问号)

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
'''
Administrator 
2018/10/9 
'''
import pymysql
# 创建连接

conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='ss@123', db='sqlexample',charset='utf8')
# 创建游标
cursor = conn.cursor()
# cursor.execute("insert into class (caption) VALUES ('中午补习班')")
cursor.execute("delete from class where caption='中午补习班'")
# r=cursor.execute("select * from class")
# print(r)

  

连接参数里加上 charset='utf8'

posted @ 2018-10-09 15:50  巨兽~墨菲特  阅读(199)  评论(0编辑  收藏  举报