擅长:python、mysql、java
<p>在主for循环中尝试这些更改,以使用pythons生成器并列出理解功能。</p>
<pre><code>def permCount(permList):
SQLexpression = "SELECT Count(*) FROM Table WHERE "
for perm in permList: # if you need the i for other reason, you could write:
# for i, perm in enumerate(permList)
a, b, c = [str(_) for _ in perm]
SQLexpression += "(A=" + a + " AND B=" + b + \
" AND C=" + c + ") OR "
SQLexpression = SQLexpression[:-4] + ";" # Trim the last " OR "
</code></pre>