|,>和<在numpy数据类型中

Lee*_*Lee 5 python numpy

这可能是一个非常愚蠢的问题,但我试图像谷歌关键字一样less and greater signs in data type of numpy,没有找到参考.

在文档中numpy,

x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', float), ('y', int)])
Run Code Online (Sandbox Code Playgroud)

输出

array([(1.0, 2), (3.0, 4)],
      dtype=[('x', '<f8'), ('y', '<i4')])
Run Code Online (Sandbox Code Playgroud)

但在我的电脑上,输出是

array([(1.0, 2), (3.0, 4)],
      dtype=[('x', '>f8'), ('y', '>i4')])
Run Code Online (Sandbox Code Playgroud)

做什么<和>在dtype平均为什么会有区别?

Ima*_*ngo 7

关键字<和>代表字节顺序,也就是字节顺序.它是存储数字的字节的顺序(当数字由超过1个字节组成时,例如int16,int32,float32 ......).这个参考页面为您提供了numpy所需的所有信息,但总结如下:

  • | :它没有字节顺序,因为它是冗余的(在单字节数字或字符串上)

  • < :小端

  • > :big-endian

正如@tobias_k和@RobertKern指出的那样,默认的 endianess,如果没有指定,则取决于系统.