我试图将 input
变量用于 SELECT
语句但是得到以下错误 .
这是我的代码:
sheetname=input("Enter the name of the SEO Analysis sheet:")
cur=conn.execute("select * from seo_info where url like '%?%'",sheetname,)
print(cur.fetchall())
这是一个错误:
File "E:/Python/SEO_Project2.py", line 40, in <module>
cur=conn.execute("select * from seo_info where url like '%?%'",sheetname,)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 0, and there are 9 supplied.
这是another question,它解决了问题的一部分,但它仍然给我错误 .
也许我在代码中遗漏了一些东西?
2 回答
我做的 !
你不需要围绕
?
使用括号,所以你可以使用list
实现你想要的,作为execute
的第二个参数:或
tuple
: