【发布时间】:2020-10-28 18:53:40
【问题描述】:
我正在尝试将二进制文件解析器从 Python 转换为 Julia。我正在努力弄清楚如何以特定格式解压缩二进制流。我发现 this discourse thread 这正是我想要做的,但它是从 2017 年开始的,似乎没有一个可行的解决方案。有人有解决办法吗?
在 Python 中是这样的:
In [22]: struct.unpack('>idi', b'\x00\x00\x00\x17@\t\x1e\xb8Q\xeb\x85\x1f\x00\x00\x00*')
Out[22]: (23, 3.14, 42)
在 Julia 我在这里:
data = open(filename, "r")
seek(data, 0)
# now I want to get the first 12 bytes of the file and convert to a string.. and am stumped..
【问题讨论】:
-
最近没试过,不过github.com/pao/StrPack.jl可能值得一看
标签: julia binaryfiles binary-data