Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
930 views
in Technique[技术] by (71.8m points)

python - Determine the endianness of a numpy array

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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]: '='

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...