""" ndarray的屬性(dtype,shape,ndim,size,itemsize) """ import numpy as np # 創建維度3x3的ndarray數組 data = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) # 打印屬性 print("形狀:", data.shape) print("維數:", data.ndim) print("數據類型:", data.dtype) print("元素個數:", data.size)
形狀: (3, 3) 維數: 2 數據類型: int32 元素個數: 9 一個數組元素的字節長度: 4