Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92c1a90

Browse files
Issue #28513: Documented command-line interface of zipfile.
1 parent 38adbfa commit 92c1a90

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Doc/library/zipfile.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,4 +574,61 @@ Instances have the following attributes:
574574

575575
Size of the uncompressed file.
576576

577+
578+
.. _zipfile-commandline:
579+
.. program:: zipfile
580+
581+
Command-Line Interface
582+
----------------------
583+
584+
The :mod:`zipfile` module provides a simple command-line interface to interact
585+
with ZIP archives.
586+
587+
If you want to create a new ZIP archive, specify its name after the :option:`-c`
588+
option and then list the filename(s) that should be included:
589+
590+
.. code-block:: shell-session
591+
592+
$ python -m zipfile -c monty.zip spam.txt eggs.txt
593+
594+
Passing a directory is also acceptable:
595+
596+
.. code-block:: shell-session
597+
598+
$ python -m zipfile -c monty.zip life-of-brian_1979/
599+
600+
If you want to extract a ZIP archive into the specified directory, use
601+
the :option:`-e` option:
602+
603+
.. code-block:: shell-session
604+
605+
$ python -m zipfile -e monty.zip target-dir/
606+
607+
For a list of the files in a ZIP archive, use the :option:`-l` option:
608+
609+
.. code-block:: shell-session
610+
611+
$ python -m zipfile -l monty.zip
612+
613+
614+
Command-line options
615+
~~~~~~~~~~~~~~~~~~~~
616+
617+
.. cmdoption:: -l <zipfile>
618+
619+
List files in a zipfile.
620+
621+
.. cmdoption:: -c <zipfile> <source1> ... <sourceN>
622+
623+
Create zipfile from source files.
624+
625+
.. cmdoption:: -e <zipfile> <output_dir>
626+
627+
Extract zipfile into target directory.
628+
629+
.. cmdoption:: -t <zipfile>
630+
631+
Test whether the zipfile is valid or not.
632+
633+
577634
.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,11 @@ C API
471471
- Issue #26754: PyUnicode_FSDecoder() accepted a filename argument encoded as
472472
an iterable of integers. Now only strings and bytes-like objects are accepted.
473473

474+
Documentation
475+
-------------
476+
477+
- Issue #28513: Documented command-line interface of zipfile.
478+
474479
Tests
475480
-----
476481

0 commit comments

Comments
 (0)