import numpy as np
b = np.arange(15)
b.shape=(3,5)
print(b)
import numpy as np
b = np.arange(15)
a = b.reshape(3,5)
print(a)
指定行数后,列数用-1,列数可以自动进行计算
import numpy as np
b = np.arange(15)
a = b.reshape(3,-1)
print(a)
shape[0] 是行数 shape[1]是列数