import numpy as ap numpy主要用来创建vectors和matrics,solve linear operations and generate random entries. 创建数组 列表[]构建数组 >>> a = np.array([1,2,3,4]) >>> a.size 4 # 4个元素 >>> a.shape (4,) # 4行1列 >>> print(a) [1 2 3 4] 数组a 1 2 3 4 行列向量转换 >>> a.shape=(1,4) >>> print(a) [[1 2 3 4]] c1 c2 c3 c4 1 2 3 4 >>> a.reshape(2,2) array([[1, 2], [3, 4]]) c1 c2 1 2 3 4 取元素 >>> b = a.reshape(2,2) >>> print(b) [[1 2] [3 4]] >>> b[0,:] # 取第1……

阅读全文