在Python 3中,我试图在sqlite表上进行简单查询,用户输入表名。但是我无法将输入变量添加到查询中。部分代码如下:
choice = input ("Enter table name ")
c.execute("SELECT * FROM ?", choice)
print(c.fetchall())
ERRORMSG。是:
sqlite3.OperationalError: near "?": syntax error
我尝试了不同的变化,没有运气。有人知道是否有好的解决方案?
谢谢,-Espen