python中dtype,type,astype的区别

之前在Python的学习中老师教过type()的用法,今天在nampy中看老师都是用.dtype的语句

在网上查了下具体的区别

函数名称用法
type 返回参数的数据类型
dtype 返回数组中元素的数据类型
astype

数据类型转换

type()

#type用于获取数据类型
import numpy as np#使用np代替numpy
a=[1,2,3]#赋值a一个list列表
print(type(a))#打印输出a的type
#>>><class 'list'>
b=np.array(a)
print(type(b))
#>>><class 'numpy.ndarray'>








posted @ 2022-04-06 17:54  Wy3年半  阅读(295)  评论(0)    收藏  举报