擅长:python、mysql、java
<p>使用优化的代码:</p>
<pre><code>from random import randint
Index=['A','B','C','D','E','F','G','H']
Board=[["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",],
["Z","Z","Z","Z","Z","Z","Z","Z",]]
RanRow=randint(0, 7)
RanIndex=randint(0, 7)
CompGuess = Board[RanRow][RanIndex]
if CompGuess in ["C" , "D", "S", "B"]:
#Do something
else:
#Do something
</code></pre>