numpy.ndarray.dtype#
attribute
- ndarray.dtype#
数组元素的数据类型.
警告
不建议设置
arr.dtype,将来可能会弃用. 设置将替换dtype而不修改内存(另请参阅ndarray.view和ndarray.astype).- 参数:
- None
- 返回:
- dnumpy dtype 对象
参见
ndarray.astype将数组中包含的值转换为新的数据类型.
ndarray.view创建同一数据的视图,但具有不同的数据类型.
numpy.dtype
示例
>>> import numpy as np >>> x = np.arange(4).reshape((2, 2)) >>> x array([[0, 1], [2, 3]]) >>> x.dtype dtype('int64') # may vary (OS, bitness) >>> isinstance(x.dtype, np.dtype) True