Python使用shape计算矩阵的行和列

shape函数是numpy.core.fromnumeric中的函数,它的功能是读取矩阵的长度。

1 >>> a=mat([[1,2,3],[5,6,9]]);
2 >>> a
3 matrix([[1, 2, 3],
4         [5, 6, 9]])
5 >>> shape(a)[0]
6 2
7 >>> shape(a)[1]
8 3

如上面的a矩阵,2行3列;计算行使用shape(a)[0];计算列使用shape(a)[1];

原文地址:https://www.cnblogs.com/chamie/p/4847261.html