numpy多维数组的切片操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_22659021/article/details/78776674


import numpy as np

item = np.array([[1,4,5],[5,3,6],[8,15,33]])
print(item[0,:])
print(item[1,:])
print(item[2,:])
print(item[:,0])
print(item[:,1])
print(item[:,2])

输出:


[1 4 5]
[5 3 6]
[ 8 15 33]
[1 5 8]
[ 4  3 15]
[ 5  6 33]

因此,数字在前的时候表示相应的行向量,数字在后的时候表示相应的列向量

猜你喜欢

转载自blog.csdn.net/sinat_22659021/article/details/78776674