python的dtype可用对象有哪些?

dtype() 返回数据元素的数据类型(int、float等)

type() 返回数据结构类型(list、dict、numpy.ndarray 等)

astype() 改变np.array中所有数据元素的数据类型。

能用dtype() 才能用 astype()。

由于 list、dict 等可以包含不同的数据类型,因此不可调用dtype()函数,但是其他类型都可以调用dtype。

示例:

 a = np.array([0.213132, 1.032123, 2.000212])
 a.dtype

运行结果:

dtype('float64')

更多Python知识,请关注:云海天python教程网!!

来源:PY学习网:原文地址:https://www.py.cn/article.html

hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » python的dtype可用对象有哪些?