NumPy多维数组的数据类型转换方法
本篇内容主要讲解“NumPy多维数组的数据类型转换方法”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“NumPy多维数组的数据类型转换方法”吧!
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license()" for more information.>>> import numpy as np>>> a = np.arange(12).reshape(3,4)>>> a array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]])>>> a.dtype dtype('int32')>>> b = np.array(a, dtype=np.float32)>>> b array([[ 0., 1., 2., 3.], [ 4., 5., 6., 7.], [ 8., 9., 10., 11.]], dtype=float32)>>> b.dtype dtype('float32')>>> >>>
到此,相信大家对“NumPy多维数组的数据类型转换方法”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!