擅长:python、mysql、java
<p>dbapi中的参数替换只用于值,而不是表或字段。您将需要使用普通字符串替换:</p>
<pre><code>selectQ ="""SELECT * FROM %s WHERE %s = %%s;""" % (self.table,self.columnSpecName)
self.db.execute(selectQ,(idKey,))
return self.db.store_result()
</code></pre>
<p>注意,值占位符有一个双<code>%</code>-这是为了让它在初始字符串替换时保持独立。在</p>