首页 > 代码库 > Python之Numpy

Python之Numpy

import numpy as np

 

1.创建

a = np.array([[0,1],[0,1]])

 

2.合并

a =np.array([[1,2],[4,5]])

b =np.array([[9,8],[6,5]])

np.concatenate((a,b))

array([[1, 2,], [4, 5], [9, 8], [6, 5]])

 

3.大小

a = np.array([[1,2],[3,4]])

np.shape(a) #结果为(2, 2)

np.shape(a)[0]#结果为2

Python之Numpy