numpy.lib.format.dtype_to_descr#

lib.format.dtype_to_descr(dtype)[source]#

从 dtype 获取可序列化的描述符。

dtype 对象的 .descr 属性无法通过 dtype() 构造函数进行往返转换。像 dtype('float32') 这样的简单类型,其 descr 看起来像一个名称为空字段的记录数组。dtype() 构造函数将其解释为提供默认名称的请求。相反,我们构建一个可以传递给 dtype() 的描述符。

参数:
dtypedtype

将要写入磁盘的数组的 dtype。

返回:
descrobject

一个可以传递给 numpy.dtype() 以复制输入的 dtype 的对象。