简单地说,我想(如果可能的话)将Ruby Marshal转储(.dat)文件加载到Python中并将其解析为可读的内容。我查看了Pickle,Marshal和RubyMarshal模块,但最终每次都出错。 发生了以下错误:
Pickle:
Traceback (most recent call last):
File "C:\Users\User\Saved Games\unmarshal\unmarsh.py", line 2, in <module>
ma = pickle.load(open('file.dat','rb'))
_pickle.UnpicklingError: invalid load key, '\x04'.
元帅:
Traceback (most recent call last):
File "C:\Users\User\Saved Games\unmarshal\unmarsh.py", line 2, in <module>
ma = marshal.load(open('file.dat','rb'))
ValueError: bad marshal data (unknown type code)
RubyMarshal(使用他们的基本示例)没有错误,但它没有完成我所追求的,意味着它保持不变。
任何有关这些的见解都非常有用。
答案 0 :(得分:0)
有图书馆:RubyMarshal
from rubymarshal.reader import load
import gzip
with gzip.open('latest_specs.4.8.gz', 'rb') as latest_specs:
print(load(latest_specs))