(1366, "Incorrect string value: '\\xF3\\xB0\\x84\\xBC</...' for column 'content' at row 1")
插数据库报错
(1366, "Incorrect string value: '\\xF3\\xB0\\x84\\xBC</...' for column 'content' at row 1")
改编码utf8mb4解决
#!/usr/bin/env python
# coding:utf8
# author:Z time:2018/7/25
import requests
from bs4 import BeautifulSoup
import pymysql
url='http://www.5bite.com/post/5234.html'
html=requests.get(url)
soup=BeautifulSoup(html.text,'lxml')
content=soup.select('body > div.inner.container > main > article > div.entry') connect = pymysql.Connect(
host='127.0.0.1',
port=3306,
user='root',
passwd='',
db='abc',
charset='utf8'
)
cursor = connect.cursor() cursor.execute("SET names 'utf8mb4'")#utf8mb4 # 插入数据
sql2 = """
INSERT INTO aa (content)
VALUES ('%s')
""" data = tuple(content) try :
if True:
cursor.execute(sql2 % data)
connect.commit()
print('成功插入cnstock 1 条数据')
cursor.close()
connect.close()
else: print('已有数据')
cursor.close()
connect.close() except Exception as e:
print(e)
详细解释
https://www.cnblogs.com/z-x-y/p/9365626.html
(1366, "Incorrect string value: '\\xF3\\xB0\\x84\\xBC</...' for column 'content' at row 1")的更多相关文章
- 解决pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x8C\\xB8' for column 'headline' at row 1")
解决pymysql.err.InternalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x8C\\xB8' for column ...
- java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column 'Content' at row 1
在尝试将 emoji 表情符号 插入MySQL数据库时,遇到以下错误信息: ### The error occurred while setting parameters ### SQL: INSER ...
- Incorrect string value: '\xF0\x9F\x93\xB7</...' for column 'content' at row 1
出现原因:当insert数据中有表情时发生.而这些表情是按照4个字节一个单位进行编码的,而我们使用的utf-8编码在mysql数据库中默认是按照3个字节一个单位进行编码的. 解决方法:将表字段字符集设 ...
- 让Mysql支持Emoji表情,解决[Err] 1366 - Incorrect string value: '\xF0\xA3\x84\x83'
mysql insert内容包含表情或者unicode码时候,插入Mysql时失败了,报如下异常: java.sql.SQLException: Incorrect string value: '\x ...
- ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'name' at row 1
ERROR 1366 (HY000): Incorrect string value: '\xD5\xC5\xC8\xFD' for column 'name' at row 1 数据库字符集问 ...
- Incorrect string value: '\xF0\xA1\xA1\x92' for column 'herst' at row 1
Incorrect string value: '\xF0\xA1\xA1\x92' for column 'herst' at row 1[转] 1.一般来说MySQL(小于5.5.3)字符集设置为 ...
- Django1.10+Mysql 5.7存储emoji表情,报Incorrect string value: '\\xF0\\x9F\\x90\\xA8' for column 'signature' at row 1的解决方法
问题: 在做webapp项目的时候,用户提交emoji数据,控制台报错:Incorrect string value: '\\xF0\\x9F\\x90\\xA8' for column 'signa ...
- 表情存储异常--mybatis抛出异常(java.sql.SQLException: Incorrect string value: '\xF0\x9F\x92\x94' for column 'name' at row 1)
文章参考 https://blog.csdn.net/junsure2012/article/details/42171035 https://www.cnblogs.com/WangYunShuai ...
- java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'nick' at row 1
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\x8E' for column 'nick' at row 1 mysql报错 ...
随机推荐
- Storyboards Tutorial 03
这一节主要介绍segues,static table view cells 和 Add Player screen 以及 a game picker screen. Introducing Segue ...
- 爬虫:网页里元素的xpath结构,scrapy不一定就找的到
这种情况原因是html界面关联的js文件可能会动态修改DOM结构,这样浏览器完成了动态修改DOM,在 浏览器上看到的DOM结构,就和后台抓到的DOM结构不通 举例:新浪微博发的微博,在浏览器通过fir ...
- TensorFlow笔记二:线性回归预测(Linear Regression)
代码: import tensorflow as tf import numpy as np import xlrd import matplotlib.pyplot as plt DATA_FILE ...
- Java内存区域与模拟内存区域异常
我把Java的内存区域画了一张思维导图,以及各区域的主要功能. 模拟Java堆溢出 Java堆用于存储对象实例.仅仅要不断地创建对象而且保证GC ROOTS到对象之间有可达路径避免被回收机制清除.就能 ...
- iptables和DNS
1.iptables防火墙 表→链→规则 filter表 数据过滤表 NAT表---内网和外网的地址转换 Mangle-----数据流量,通过防火墙设置流量.特殊数据包标记.太复杂,一般不用.限速工具 ...
- IP、操作系统、移动OS
IP IP地址 = 网络地址 + 主机地址/IP地址 = 网络地址 + 子网地址 + 主机地址. DNS :进行域名解析的服务器. 比如,sina.com(是域名).其实是一个 ...
- jquery方法
$.inArray(被判断的量,ArrayName); 如果存在返回索引值,如果不存在返回-1 $.unique() 数组去重 根据去重前后的长度,判断是否有重复 $.each(被遍历的数组,f ...
- C#比較对象的相等性
对于相等的机制全部不同,这取决于比較的是引用类型还是值类型.以下分别介绍引用类型和值类型的相等性. 1.比較引用类型的相等性 System.Object定义了三种不同的方法,来比較对象的相等性:Ref ...
- 模拟IE各种版本的方法
下载360极速浏览器.开启“兼容模式” 默认会是IE7.可以通过控制台(Ctrl + shift + I)调整各个版本
- FZU2125:简单的等式
Problem Description 如今有一个等式例如以下:x^2+s(x,m)x-n=0. 当中s(x,m)表示把x写成m进制时,每一个位数相加的和.如今,在给定n,m的情况下,求出满足等式的最 ...