【发布时间】:2015-07-31 16:56:23
【问题描述】:
在使用 python 和 mysql 时遇到了一些棘手的问题。为简单起见,以下代码返回变量“field”中的任何内容,它是一个字符串。例如“用户名”或“密码”。
options = [field, userID]
entries = cursor.execute('select (?) from users where id=(?)', options).fetchall()
print(entries);
如果我删除第一个 (?) 并只使用实际名称(如“用户名”),则此代码可以正常工作。谁能提供一些意见?
【问题讨论】: