MOON
Server: Apache/2.2.31 (Unix) mod_ssl/2.2.31 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4
System: Linux csr818.wilogic.com 2.6.18-419.el5xen #1 SMP Fri Feb 24 22:50:37 UTC 2017 x86_64
User: digitals (531)
PHP: 5.4.45
Disabled: NONE
Upload Files
File: //usr/share/doc/python-docs-2.4.3/html/lib/module-zipfile.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-tarfile.html" />
<link rel="prev" href="module-bz2.html" />
<link rel="parent" href="someos.html" />
<link rel="next" href="zipfile-objects.html" />
<meta name='aesop' content='information' />
<title>7.18 zipfile -- Work with ZIP archives</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.17.3 One-shot (de)compression"
  href="node408.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="7. Optional Operating System"
  href="someos.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="7.18.1 ZipFile Objects"
  href="zipfile-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node408.html">7.17.3 One-shot (de)compression</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="zipfile-objects.html">7.18.1 ZipFile Objects</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0091800000000000000000">
7.18 <tt class="module">zipfile</tt> --
         Work with ZIP archives</A>
</H1>

<P>
<A NAME="module-zipfile"></A>

<P>

<span class="versionnote">New in version 1.6.</span>

<P>
The ZIP file format is a common archive and compression standard.
This module provides tools to create, read, write, append, and list a
ZIP file.  Any advanced use of this module will require an
understanding of the format, as defined in
<em class="citetitle"><a
 href="http://www.pkware.com/appnote.html"
 title="PKZIP Application
Note"
 >PKZIP Application
Note</a></em>.

<P>
This module does not currently handle ZIP files which have appended
comments, or multi-disk ZIP files.

<P>
The available attributes of this module are:

<P>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-2851' xml:id='l2h-2851' class="exception">error</tt></b></dt>
<dd>
  The error raised for bad ZIP files.
</dd></dl>

<P>
<dl><dt><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2852' xml:id='l2h-2852' class="class">ZipFile</tt></b>
<dd>
  The class for reading and writing ZIP files.  See
  ``<em class="citetitle"
 >ZipFile Objects</em>'' (section <A href="zipfile-objects.html#zipfile-objects">7.18.1</A>) for
  constructor details.
</dl>

<P>
<dl><dt><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2853' xml:id='l2h-2853' class="class">PyZipFile</tt></b>
<dd>
  Class for creating ZIP archives containing Python libraries.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-2854' xml:id='l2h-2854' class="class">ZipInfo</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>filename</var><big>[</big><var>, date_time</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
  Class used to represent information about a member of an archive.
  Instances of this class are returned by the <tt class="method">getinfo()</tt> and
  <tt class="method">infolist()</tt> methods of <tt class="class">ZipFile</tt> objects.  Most users
  of the <tt class="module">zipfile</tt> module will not need to create these, but
  only use those created by this module.
  <var>filename</var> should be the full name of the archive member, and
  <var>date_time</var> should be a tuple containing six fields which
  describe the time of the last modification to the file; the fields
  are described in section <A href="zipinfo-objects.html#zipinfo-objects">7.18.3</A>, ``ZipInfo Objects.''
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-2855' xml:id='l2h-2855' class="function">is_zipfile</tt></b>(</nobr></td>
  <td><var>filename</var>)</td></tr></table></dt>
<dd>
  Returns <code>True</code> if <var>filename</var> is a valid ZIP file based on its magic
  number, otherwise returns <code>False</code>.  This module does not currently
  handle ZIP files which have appended comments.
</dl>

<P>
<dl><dt><b><tt id='l2h-2856' xml:id='l2h-2856'>ZIP_STORED</tt></b></dt>
<dd>
  The numeric constant for an uncompressed archive member.
</dd></dl>

<P>
<dl><dt><b><tt id='l2h-2857' xml:id='l2h-2857'>ZIP_DEFLATED</tt></b></dt>
<dd>
  The numeric constant for the usual ZIP compression method.  This
  requires the zlib module.  No other compression methods are
  currently supported.
</dd></dl>

<P>
<div class="seealso">
  <p class="heading">See Also:</p>

  <dl compact="compact" class="seetitle">
    <dt><em class="citetitle"><a href="http://www.pkware.com/appnote.html"
        >PKZIP Application
            Note</a></em></dt>
    <dd>Documentation on the ZIP file format by Phil
            Katz, the creator of the format and algorithms used.</dd>
  </dl>

<P>
<dl compact="compact" class="seetitle">
    <dt><em class="citetitle"><a href="http://www.info-zip.org/pub/infozip/"
        >Info-ZIP Home Page</a></em></dt>
    <dd>
            Information about the Info-ZIP project's ZIP archive
            programs and development libraries.</dd>
  </dl>
</div>

<P>

<p><br /></p><hr class='online-navigation' />
<div class='online-navigation'>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>

<UL CLASS="ChildLinks">
<LI><A href="zipfile-objects.html">7.18.1 ZipFile Objects</a>
<LI><A href="pyzipfile-objects.html">7.18.2 PyZipFile Objects</a>
<LI><A href="zipinfo-objects.html">7.18.3 ZipInfo Objects</a>
</ul>
<!--End of Table of Child-Links-->
</div>

<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="7.17.3 One-shot (de)compression"
  href="node408.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="7. Optional Operating System"
  href="someos.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="7.18.1 ZipFile Objects"
  href="zipfile-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="node408.html">7.17.3 One-shot (de)compression</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="someos.html">7. Optional Operating System</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="zipfile-objects.html">7.18.1 ZipFile Objects</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.3, documentation updated on 29 March 2006.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>