很有效的方法:
python向mysql数据库中写入的数据出现单引号和双引号处理方法
调用python的MySQLdb模块中的escape_string函数
import MySQLdb
MySQL.escape_string(x) 其中x为需要被处理的字符串内容。
或者直接采用
from MySQLdb import escape_string
escape_string(x)
参考链接:
https://blog.csdn.net/lk7688535/article/details/78053938
https://blog.csdn.net/luoxiandong2/article/details/73803332