确定numpy数组的字节序 [英] Determine the endianness of a numpy array

查看:138
本文介绍了确定numpy数组的字节序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 numpy.array ,我想找出基础表示中使用的字节序。

I have a numpy.array and I want to find out what endianness is used in the underlying representation.

记录了 byteorder 属性此处,但没有给出的示例显示它与数组一起使用。

A byteorder property is documented here, but none of the given examples show it being used with an array.

推荐答案

byteorder 是数据类型的对象 dtype 属性,因此您需要执行以下操作:

byteorder is a data type objects dtype attribute so you need to do this:

In [10]: import numpy as np

In [11]: arr = np.array([1,2,3])

In [12]: arr.dtype.byteorder
Out[12]: '='

这篇关于确定numpy数组的字节序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆