V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
? Learn Python the Hard Way
Python Sites
? PyPI - Python Package Index
? http://diveintopython.org/toc/index.html
? Pocoo
值得关注的项目
? PyPy
? Celery
? Jinja2
? Read the Docs
? gevent
? pyenv
? virtualenv
? Stackless Python
? Beautiful Soup
? 结巴中文分词
? Green Unicorn
? Sentry
? Shovel
? Pyflakes
? pytest
Python 编程
? pep8 Checker
Styles
? PEP 8
? Google Python Style Guide
? Code Style from The Hitchhiker's Guide
whereFly
V2EX  ?  Python

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

  •  
  •   whereFly · 219 天前 · 2174 次点击
    这是一个创建于 219 天前的主题,其中的信息可能已经有所发展或是发生改变。
    第 1 条附言  ·  218 天前
    我下载的文件是 a.tar 这样的,究竟是什么压缩格式也不知道。
    6 条回复  ?  2023-10-08 11:30:00 +08:00
    nowheremanx
        1
    nowheremanx  
       219 天前   ?? 1
    换个思路,考虑下 subprocess 召唤 unrar
    monkeyWie
        2
    monkeyWie  
       219 天前
    这种问题问 chatGPT 就行了
    nuk
        3
    nuk  
       219 天前   ?? 2
    tar 格式根本就不支持加密。。。
    Kirscheis
        4
    Kirscheis  
       219 天前
    tar 本身没有加密,一般是传输前外部加密,可以用 python-gnupg 库解密

    https://gnupg.readthedocs.io/en/latest/
    Maysec
        5
    Maysec  
       218 天前
    tar 是类似 iso 的格式 不支持加密吧
    netsys
        6
    netsys  
       216 天前
    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("使用密码解压成功")
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2788 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:42 · PVG 10:42 · LAX 19:42 · JFK 22:42
    Developed with CodeLauncher
    ? Do have faith in what you're doing.


    http://www.vxiaotou.com