NumPy数组的属性
NumPy数组的属性
| 属性 | 说明 |
|---|---|
| ndim | 维度的个数,即多少维 |
| shape | 数组的形状,比如m行n列 |
| size | 元素的个数 |
| dtype | 元素的类型 |
import numpy as np
arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print("arr:")
print(arr)
print("ndim=", arr.ndim)
print("shape=", arr.shape)
print("size=", arr.size)
print("dtype=", arr.dtype)
浙公网安备 33010602011771号