06-numpy-笔记-shape

shape 是返回 np.mat 的形状的。

1. 作为 mat 的成员变量,a.shape

2. 作为 np 的成员函数,np.shape

 

 

>>> import numpy as np
>>> 
>>> a = np.mat([[1,2,3],[4,5,6]])
>>> a
matrix([[1, 2, 3],
        [4, 5, 6]])
>>> a.shape
(2, 3)
>>>
>>> a.shape() # 错误,不可以执行
>>>
>>>
>>> np.shape(a)
(2, 3)
>>> np.shape(a)[0]
2
>>> np.shape(a)[1]
3
>>> np.shape(a)[2] # 错误,越界

  

 

posted @ 2018-04-21 09:48  路边的十元钱硬币  阅读(204)  评论(0编辑  收藏  举报