标签:medium 解决 pos article 爬虫 通过 name l数据库 har
用Python通过pymysql往MySQL数据库中插入数据时,插入的字段含有中文,出现异常:
‘latin-1‘ codec can‘t encode characters in position 62-66: ordinal not in range(256)
数据库连接语句:
db=pymysql.connect(host="localhost",user="root",passwd="mysql",db="test_db")
把数据库连接语句改为:
db=pymysql.connect(host="localhost",user="root",passwd="mysql",db="test_db",port=3306,charset=‘utf8‘)
标签:medium 解决 pos article 爬虫 通过 name l数据库 har
原文地址:https://www.cnblogs.com/php-linux/p/9683089.html