reshape 变形

53.7 reshape 变形

a.reshape(行, 列) 改变形状,元素总数不变。

a.flatten() 展平为一维。

reshape

# ========================================
# 示例:reshape
# ========================================
import numpy as np

a = np.arange(12)
print(a.reshape(3, 4))