按照psycopg2文档(http://initd.org/psycopg/docs/connection.html)就指出:Python的psycopg2串插格式VS%
Warning Never, never, NEVER use Python string concatenation (+) or string parameters interpolation (%) to pass variables to a SQL query string. Not even at gunpoint.
在警告它专门引用没有做这样的事情:
cur.execute(SQL % data)
该警告也适用于以下使用格式?
cur.execute(SQL.format(data))
我不知道格式的内容,但是我假设它是用%字符串互操作其下将使得它的使用不妥当
我相信你的意思是可能的*,而不是不可能的 – user1077071
@ user1077071澄清。 –