np.vstack(tup)使用

沿着竖直方向将矩阵堆叠起来。
Note: the arrays must have the same shape along all but the first axis. 除开第一维外,被堆叠的矩阵各维度要一致。

import numpy as np
arr1 = np.array([1, 2,3])
arr2 = np.array([4, 5, 6])
res = np.vstack((arr1, arr2))
print(res)#[[1 2 3]
        # [4 5 6]]
print(res[:, 0])#取出res的第一列[1 4]
print(res[:, 1])#取出res的第一列[2 5]

猜你喜欢

转载自blog.csdn.net/weixin_38145317/article/details/89639906
tup
np