品易云推流 关闭
文章详情页
文章 > Python常见问题 > python的dtype可用对象有哪些?

python的dtype可用对象有哪些?

头像

 Ly

2020-06-13 15:26:122989浏览 · 0收藏 · 0评论

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自学网!!

关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图