擅长:python、mysql、java
<p>使用NumPy索引类似于MATLAB</p>
<pre><code> import numpy as np
A=np.empty((2,3,3))
A.shape
#(2L, 3L, 3L)
A[0,1,2] # element at index 0,1,2
#0.0
A[0,:,:] # 3x3 slice at index 0
#array([[ 0., 0., 0.],
# [ 0., 0., 0.],
# [ 0., 0., 0.]])
A[1,1,:] # 1-D array of length 3
#array([ 0., 0., 0.]
</code></pre>