擅长:python、mysql、java
<p><a href="https://stackoverflow.com/a/52334956/4799172">sacul</a>已经介绍了生成输出的更有效的方法。但是,如果你想使用数组,你的二维矩阵索引是错误的。在</p>
<p>至少对我来说,这有点不直观,但你需要使用:</p>
<pre><code>myMatrix[[all_row_indices], [all_column_indices]]
</code></pre>
<p>以下内容将满足您的期望:</p>
^{pr2}$
<p>您可以在<a href="https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.indexing.html#advanced-indexing" rel="nofollow noreferrer">documentation</a>中看到有关高级索引的更多信息</p>