擅长:python、mysql、java
<p>您可以直接使用python列表,如下所示。它的行为类似于SQL中的IN运算符,并且在不抛出任何错误的情况下处理空白列表。</p>
<pre><code>data=['UK','France']
sql='SELECT * from countries WHERE country = ANY (%s)'
cur.execute(sql,(data,))
</code></pre>
<p>资料来源:
<a href="http://initd.org/psycopg/docs/usage.html#lists-adaptation" rel="nofollow noreferrer">http://initd.org/psycopg/docs/usage.html#lists-adaptation</a></p>