我需要使用python提取一些壓縮爲.xz文件的文本文件。無法用python提取.xz文件「tarfile.ReadError:文件無法成功打開」
我的代碼只是
import tarfile
tarfile.open('file.xz')
但這種失敗,我已經嘗試了這許多.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文件沒有被破壞,可以用gnome檔案管理器打開。
我搜索了這個問題,發現this bug report,但我不確定現在要做什麼。
它不應該是:'tarfile.open('file.xz')' – hjpotter92
是一個'.tar.xz'還是一個簡單的'.xz'文件? – falsetru
@ hjpotter92是的,應該是。我的實際代碼有'' – Qwertie