一维
# 使用列表创建一维数组 my_list = [1, 2, 3, 4, 5] # 将列表转换为NumPy数组 my_array = np.array(my_list)
[1 2 3 4 5]
<class 'numpy.ndarray'>
二维
# 二维数组,3行4列 arr_2d = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
三维
# 三维数组,2个二维数组,每个数组是3行4列 arr_3d = np.array([[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]], [[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]])
标签:arr,创建,二维,数组,numpy,np,array,my From: https://www.cnblogs.com/mxleader/p/17864118.html