擅长:python、mysql、java
<p>您可以使用IN关键字根据列表进行筛选。你知道吗</p>
<pre><code>party_ids= [4, 3, 1, 2]
def initializegame(party_ids):
#Get selected party members IDS
print(party_ids)
#Obtain Speeds
ids_string = ','.join(str(id) for id in party_ids)
mycursor.execute("SELECT startspeed FROM characters WHERE CharID IN ({0})".format(ids_string))
myspeeds=mycursor.fetchall()
print(myspeeds)
print("done")
</code></pre>
<p>您可以从这个<a href="http://www.mysqltutorial.org/sql-in.aspx" rel="nofollow noreferrer">MySQL blog tutorial</a>中找到有关IN关键字及其工作方式的更多信息。你知道吗</p>