使用numpy生成如图所示的三维数组aArray打印输出该三维数组使用flatten方法将该三维数组降维后打印输出三维数组为0-17
的整数,第一维长度为2,第二维长度为3,第三维长度为3。
import numpy as np
aArray = np.arange(18).reshape((2,3,3))
print(aArray)
# 降维后打印输出
print(aArray.flatten())
输出结果:
[[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]]
[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17]
原文地址: http://www.cveoy.top/t/topic/hlIC 著作权归作者所有。请勿转载和采集!