import numpy as np
c = np.array([[1,2,3],[4,5,6]])
print('2行3列')
print(c.reshape(2,3))
print('3行2列')
print(c.reshape(3,2))
print('我也不知道几行,反正是一列')
print(c.reshape(-1,1))
print('我也不知道几列,反正是一行')
print(c.reshape(1,-1))
print('不分行列,改成一串')
print(c.reshape(-1))
输出:
参考自https://www.zhihu.com/question/52684594