AttributeError: module 'pymysql' has no attribute 'escape_string'

臭大佬 2021-03-30 00:01:00 499
Python 
简介 AttributeError: module 'pymysql' has no attribute 'escape_string'

问题

AttributeError: module ‘pymysql’ has no attribute ‘escape_string’

代码

# coding:utf-8
import pymysql

# ....
s = r'sss'
ss =  pymysql.escape_string(s)

解决

# coding:utf-8
import pymysql
from pymysql.converters import escape_string


# ....
s = r'sss'
ss =  escape_string(s)