我在脚本中遇到了一些语法问题。
这有效:
c.execute('SELECT * FROM restaurants WHERE address LIKE "%Yongsan%"')
但是,我希望将"%Yongsan%"
替换为raw_input
变量,我无法弄清楚'%'符号的语法。
所以,有些事情......
t = raw_input("Enter your District: ")
g = '%',t,'%',
c.execute('SELECT * FROM restaurants WHERE address LIKE ?', g)
但是,当我执行脚本时,我收到以下错误:
"sqlite3.ProgrammingError: Incorrect number of bindings supplied.
The current statement uses 1, and there are 3 supplied."
答案 0 :(得分:0)
如果我正确理解你,这应该有效。
c.execute('SELECT * FROM restaurants WHERE address LIKE "%%%s%%"' % (raw_input('Enter your district: '),))
如果我误解你想要做什么,请告诉我。