Python矩阵

>>> n = np.arange(0, 30, 2)
>>> n

array([ 0,  2,  4,  6,  8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28])

>>> n=n.reshape(3,5)
>>> n
array([[ 0,  2,  4,  6,  8],
       [10, 12, 14, 16, 18],
       [20, 22, 24, 26, 28]])
>>> n.shape[0]
3
>>> n.shape[1]

5

>>> n.shape[0:1]

(3,)

>>> n.shape[1:2]
(5,)

>>> n.shape[0:2]
(3, 5)

猜你喜欢

转载自blog.csdn.net/sinat_39372048/article/details/81011957