我想解压一个包含几个文件夹和文件的 .xz 文件,但是我没有找到使用 lzma 模块直接解压的方法。这是我看到的 decompress 方法:
In [1]: import lzma
In [2]: f = lzma.decompress("test.tar.xz")
---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-2-3b08bf488f9d> in <module>()
----> 1 f = lzma.decompress("test.tar.xz")
error: unknown file format
还有其他方法可以解压缩这个文件,使其创建结果文件夹吗?
tarfile.ReadError: file could not be opened successfully
。相反,我使用了https://dev59.com/HVgQ5IYBdhLWcg3w4n7z中的答案。`contents = lzma.open('file.xz').read()` - themaninthewoods