擅长:python、mysql、java
<p>不要使用列表列表,使用<code>numpy.ndarray</code>将使您所需的索引/切片/转换更容易。在</p>
<pre><code>>>> import numpy as np
>>> x = np.array(range(1, 28)).reshape((3, 3, 3))
>>> x
array([[[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9]],
[[10, 11, 12],
[13, 14, 15],
[16, 17, 18]],
[[19, 20, 21],
[22, 23, 24],
[25, 26, 27]]])
>>> x[:,0,0]
array([ 1, 10, 19])
>>> x[0,:,0]
array([1, 4, 7])
>>> x[0,0,:]
array([1, 2, 3])
</code></pre>