将多维数组改为一维数组

python学习网 2020-06-18 14:59:02
import  numpy
a=numpy.arange(27).reshape(3,3,3)

 
b=numpy.arange(12)
c=numpy.reshape(b,(2,3,2))   #修改为三维数组


#将多维数组修改为一维数组
d=c.reshape(12)
e=c.reshape(-1)

#通过ravel,flatten,将多维数组转化为一维数组
f=c.ravel()
g=c.flatten()

 

阅读(2416) 评论(0)