我需要使用 python 提取一些压缩为 .xz 文件的文本文件。
我的代码只是
import tarfile
tarfile.open('file.xz')
但这失败并出现错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/tarfile.py", line 1558, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
我已经在许多 .xz 文件上尝试过这个并得到了相同的结果。.xz 文件没有损坏,可以使用 gnome 存档管理器正常打开。
我搜索了问题并找到了这个错误报告,但我不确定现在要尝试什么。