首先讲np.reshape

data = np.array([1,2,3,4,5,6])

不论是使用data.reshape(2,4)或者np.reshape(data,(2,,4))都不行,因为reshape后的尺寸要和原始尺寸一样

再讲np.resize

data=np.array([1,2,3,4,5,6])

①:使用data.resize(2,4)是不可行的,会出现cannot resize this array: it does not own its data这个错误

②:若要使用data2=np.resize(data,(2,4)),若缺少元素,则会使用原数组重复的元素。

posted on 2022-05-13 09:47  little_power  阅读(864)  评论(0)    收藏  举报