Python 怎么解压带密码的 tar 呢?

216 天前
 whereFly
2168 次点击
所在节点    Python
6 条回复
nowheremanx
216 天前
换个思路,考虑下 subprocess 召唤 unrar
monkeyWie
216 天前
这种问题问 chatGPT 就行了
nuk
216 天前
tar 格式根本就不支持加密。。。
Kirscheis
216 天前
tar 本身没有加密,一般是传输前外部加密,可以用 python-gnupg 库解密

https://gnupg.readthedocs.io/en/latest/
Maysec
216 天前
tar 是类似 iso 的格式 不支持加密吧
netsys
214 天前
import tarfile

tar = tarfile.open("a.tar", "r:")

try:
tar.extractall(path=".", members=tar) # 无密码解压
print("文件解压成功")
except tarfile.ReadError:
passwd = "password" # 此处填写解压密码
tar.extractall(path=".", members=tar, pwd=passwd.encode('utf-8'))
print("使用密码解压成功")

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/979144

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX