擅长:python、mysql、java
<p>问题在于:</p>
<pre><code>for ii in range(1,min(20,cnum)):
candid=""
for w in W:
candid+=str(" "+random.choice (w)[0]).encode('utf-8')
candida.add(candid)
</code></pre>
<p>应该是的</p>
^{pr2}$
<p>但它不是惯用的python</p>
<p>你应该这么做</p>
^{3}$
<p>此外,您的脚本中还有一个潜在的sql注入</p>
<pre><code>q="SELECT fa FROM words WHERE en ='"+t+"'"
c.execute(q)
</code></pre>
<p>你应该这么做</p>
<pre><code>q="SELECT fa FROM words WHERE en =?"
c.execute(q, (t,))
</code></pre>
<p><code>(t,)</code>是一个只有一个元素的元组</p>