python向mysql数据库中写入的数据出现单引号和双引号处理方法

版权声明:本文为博主原创文章,未经博主允许不得转载。如若转载,请注明出处! https://blog.csdn.net/Homewm/article/details/81665511

很有效的方法:

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

猜你喜欢

转载自blog.csdn.net/Homewm/article/details/81665511