1.1.1 sharp shape函数是numpy.core.fromnumeric中的函数,它的功能是查看矩阵或者数组的维数。 例子: import numpy as np k = np.matrix([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) print(np.shape(k)) # 输出(3,4)表示矩阵为3行4列 print(k.shape[0]) # shape[0]输出3,为矩阵的行数 print(k.shape[1]) # 同理shape[1]输出列数 (3, 4) 3 4