函数 | 说明 |
---|---|
type() | 返回数据结构类型(list、dict、numpy.ndarray 等) |
dtype() | 返回数据元素的数据类型(int、float等)备注:1、由于 list、dict 等可以包含不同的数据类型,因此不可调用dtype()函数; 2、np.array 中要求所有元素属于同一数据类型,因此可调用dtype()函数 |
astype() | 改变np.array中所有数据元素的数据类型。备注:能用dtype() 才能用 astype() |
浅谈Python中的type()、dtype()、astype()的区别
最新推荐文章于 2022-10-28 10:42:15 发布