import numpy as np n = np.arange(10) # array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) # 查看数组的大小 n.size # # 将数组分为两行五列 n.shape = 2,5 ''' array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) ''' # 显示数组的维度 n.shape # (2, 5) # 设置数组的维度,-1 表示自动计算 n.shape = 5,-1 ''' array([[0, 1