推荐学习书目
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 · Oct 6, 2023 · 3360 views
    This topic created in 956 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Oct 6, 2023
    我下载的文件是 a.tar 这样的,究竟是什么压缩格式也不知道。
    6 replies    2023-10-08 11:30:00 +08:00
    nowheremanx
        1
    nowheremanx  
       Oct 6, 2023   ❤️ 1
    换个思路,考虑下 subprocess 召唤 unrar
    monkeyWie
        2
    monkeyWie  
       Oct 6, 2023
    这种问题问 chatGPT 就行了
    nuk
        3
    nuk  
       Oct 6, 2023   ❤️ 2
    tar 格式根本就不支持加密。。。
    Kirscheis
        4
    Kirscheis  
       Oct 6, 2023
    tar 本身没有加密,一般是传输前外部加密,可以用 python-gnupg 库解密

    https://gnupg.readthedocs.io/en/latest/
    Maysec
        5
    Maysec  
       Oct 6, 2023
    tar 是类似 iso 的格式 不支持加密吧
    netsys
        6
    netsys  
       Oct 8, 2023
    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("使用密码解压成功")
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   943 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:24 · PVG 05:24 · LAX 14:24 · JFK 17:24
    ♥ Do have faith in what you're doing.