Python压缩工具

$ sudo apt-get install unzip unrar p7zip-full
$ python3 -m pip install patool
$ python3 -m pip install pyunpack

1. unzip

2. unrar

3. p7zip

4. patool

5. pyunpack

$ python3 -m pyunpack.cli --help
usage: cli.py [-h] [-b BACKEND] [-a] [--debug] filename directory

positional arguments:
  filename              path to archive file
  directory             directory to extract to

optional arguments:
  -h, --help            show this help message and exit
  -b BACKEND, --backend BACKEND
                        auto, patool or zipfile
  -a, --auto-create-dir
                        auto create directory
  --debug               set logging level to DEBUG

Usage

$ echo hello > hello.txt
$ zip hello.zip hello.txt
$ rm hello.txt
$ python3
>>> from pyunpack import Archive
>>> Archive('hello.zip').extractall('.')
>>> open('hello.txt').read()
'hello
'
原文地址:https://www.cnblogs.com/brt2/p/13807426.html