如何从字符串中解开?
How to unpickle from string?
我有一系列使用 gzip 压缩的 Pickle 文件。由于大小问题,我读取了gzip压缩格式的文件,只在需要时才在内存中解压。也就是说,
my_zip_content = open(file_name, 'rb').read()
my_pickle_content = zlib.decompress(my_zip_content, 15 + 32)
original_content = UNPICKLE(my_pickle_content) # How ?
问题是,我找不到 API(即 UNPICKLE
)来解开字符串。任何帮助是极大的赞赏。
你想要 pickle.loads()
这意味着 "load string," 请参阅 https://docs.python.org/3/library/pickle.html#pickle.loads
我有一系列使用 gzip 压缩的 Pickle 文件。由于大小问题,我读取了gzip压缩格式的文件,只在需要时才在内存中解压。也就是说,
my_zip_content = open(file_name, 'rb').read()
my_pickle_content = zlib.decompress(my_zip_content, 15 + 32)
original_content = UNPICKLE(my_pickle_content) # How ?
问题是,我找不到 API(即 UNPICKLE
)来解开字符串。任何帮助是极大的赞赏。
你想要 pickle.loads()
这意味着 "load string," 请参阅 https://docs.python.org/3/library/pickle.html#pickle.loads