python3使用pymysql操做數據庫時字符串中含有單雙引號(""/'')的問題

錯誤信息mysql

pymysql.err.ProgrammingError: (1064, 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'fas好",\'wozhidaole知道了\'" where title = "好"\' at line 1')

解決辦法:操做以前多加一步轉化sql

pymysql.escape_string(str)
相關文章
相關標籤/搜索