1

我将如何在以下内容中转义 %:

cursor.execute('''SELECT MIN(id) FROM title WHERE provider=%s 
                  AND vendor_id LIKE "%s%"''', (provider, vendor_id_stem))
4

2 回答 2

1
cursor.execute("SELECT MIN(id) FROM title WHERE provider=%s"
               "AND vendor_id LIKE '%s%%'", (provider, vendor_id_stem))
于 2013-05-10T22:21:58.910 回答
0

将其添加为 python 变量:

cursor.execute("SELECT MIN(id) FROM title WHERE provider=%s AND 
                vendor_id LIKE %s", (provider, vendor_id_stem + '%'))
于 2013-05-10T22:22:00.797 回答