b=list(range(5))
b
[0, 1, 2, 3, 4] #列表
区别
a=np.arange(5)
a
array([0, 1, 2, 3, 4])# 矩阵
生成一个1*24的矩阵,在将她变成2*3*4的数体
c=np.arange(24).reshape(2,3,4)
c
Out[301]:
array([[[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]],
[[12, 13, 14, 15],
[16, 17, 18, 19],
[20, 21, 22, 23]]])
c.shape
Out[303]: (2, 3, 4)
c[0,0,0]
Out[305]: 0
数体的第一层楼
c[0] #同c[0,:,:] c[0,...]
Out[306]:
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
c[:,0,0] 一到二楼的00位置元素
Out[309]: array([ 0, 12])
感谢Ivan idris