当我用 python 代码读取前 4 个字节时
len = fobj.read(4)
我得到了 'o\xf2\x00\x00'。这应该是一个 int32,当我用其他工具(例如 matlab)读取文件时,它给出 62063。
有人能给我一些提示,告诉我如何将 hex 字符串转换为 python 中的 int 吗?
我读过 this hex string to int conversion discussion,但没有找到任何帮助。
感谢您的任何建议!
请您参考如下方法:
>>> import struct
>>> struct.unpack('<i', 'o\xf2\x00\x00')
(62063,)
