python3.6+mysql無法寫入中文問題

con.encoding ='utf8'

cur = con.cursor()

cur.execute("set names utf8")

config = {'charset': 'utf8',
          'db': 'ddd',
          'host': '...',
          'passwd': '×××',
          'port': 3308,
          'user': 'music'}
最好連接數據庫時,config也設定charset

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章