报错
python编码错误:UnicodeDecodeError: ‘utf8‘ codec can‘t decode
或者UnicodeDecodeError: ‘ascii‘ codec can‘t decode byte 0xcf in position 7: ordinal not in range(128)
考虑使用如下方法http://www.jb51.net/article/59297.htm
代码如下
#coding:utf-8 import sys reload(sys) sys.setdefaultencoding(‘utf8‘) import mysql.connector cnx =mysql.connector.connect(user=‘bitbear‘,password=‘bittest123‘,host=‘101.201.50.1‘,database=‘bitbear‘,charset=‘utf8‘)
参考https://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001391435131816c6a377e100ec4d43b3fc9145f3bb8056000
时间: 2024-11-05 21:37:19