时间:2020-12-25 12:00:22 | 栏目:Python代码 | 点击:次
废话不多说,直接上代码吧!
# 矩阵操作 # 将矩阵拉成向量 import numpy as np x = np.arange(10).reshape(2,5) print(x) y1 = x.ravel() y2 = x.flatten() print("y1: ",y1," y2: ",y2) print(x) """ 打印结果: [[0 1 2 3 4] [5 6 7 8 9]] y1: [0 1 2 3 4 5 6 7 8 9] y2: [0 1 2 3 4 5 6 7 8 9] [[0 1 2 3 4] [5 6 7 8 9]] """