'latin-1'codec can't encode characters in postion 52-55:ordinal not in range(256)

来源:互联网 发布:淘宝天猫8折代购原理 编辑:程序博客网 时间:2024/06/08 08:05

Python2.7.12 + MySql-python1.2.4 插入数据报错。

代码:
MySQLdb.connect(host=’localhost’,user=’root’,passwd=’123456’,db=’testdb’)

缺少:charset=’utf8’,添加即可。如下:

MySQLdb.connect(host=’localhost’,user=’root’,passwd=’123456’,db=’testdb’,charset=’utf8’)

0 0
原创粉丝点击