擅长:python、mysql、java
<p>可能您需要的是<code>numpy</code>,请参见<a href="https://stackoverflow.com/questions/6313308/get-all-the-diagonals-in-a-matrix-list-of-lists-in-python">Get all the diagonals in a matrix/list of lists in Python</a>。也许你可以用这个,像用另一种方法一样翻转它。</p>
<pre><code>if sum(board[i][i] for i in (0, 1, 2)) in (-3, 3):
true
</code></pre>