擅长:python、mysql、java
<p>一个很大的变化是重构move函数,以传递所需的令牌,并通过数学避免elif</p>
<pre><code>def move(self, token):
o = int(input(f"Its '{token}'s'move please insert 1-9"))
while not (0 < o <= 9):
print('that column is out of range')
o = int(input("please insert 1-9"))
self.board[o-1] = f"[{token}]"
self.createboard()
</code></pre>
<p>通过…使用</p>
<pre><code>move("O")
move("X")
</code></pre>