关于numpy.shape函数的理解

函数功能:显示数组的维度

例子:

import numpy as np
a=np.ones([23,45,56])#生成一个23*45*56三维数组

print(a.shape)#输出三个维度(23, 45, 56)

print(a.shape[0])#输出第一个维度23,如果第二个维度则为a.shape[1]

print(a.shape[:2])#输出第一个和第二个维度(23,45)

猜你喜欢

转载自blog.csdn.net/qq_29023939/article/details/80693798