<!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN">
<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>
<div id='top-navigation-panel' xml:id='top-navigation-panel'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<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>
<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>
<!--End of Navigation Panel-->
<H1><A NAME=
"SECTION0091800000000000000000">
7.18 <tt class=
"module">zipfile
</tt> --
Work with ZIP archives
</A>
<A NAME=
"module-zipfile"></A>
<span class=
"versionnote">New in version
1.6.
</span>
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
href=
"http://www.pkware.com/appnote.html"
This module does not currently handle ZIP files which have appended
comments, or multi-disk ZIP files.
The available attributes of this module are:
<dl><dt><b><span class=
"typelabel">exception
</span> <tt id='l2h-
2851' xml:id='l2h-
2851'
class=
"exception">error
</tt></b></dt>
The error raised for bad ZIP files.
<dl><dt><b><span class=
"typelabel">class
</span> <tt id='l2h-
2852' xml:id='l2h-
2852'
class=
"class">ZipFile
</tt></b>
The class for reading and writing ZIP files. See
>ZipFile Objects
</em>'' (section
<A href=
"zipfile-objects.html#zipfile-objects">7.18.1</A>) for
<dl><dt><b><span class=
"typelabel">class
</span> <tt id='l2h-
2853' xml:id='l2h-
2853'
class=
"class">PyZipFile
</tt></b>
Class for creating ZIP archives containing Python libraries.
<dl><dt><table cellpadding=
"0" cellspacing=
"0"><tr valign=
"baseline">
<td><nobr><b><span class=
"typelabel">class
</span> <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>
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><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>
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><dt><b><tt id='l2h-
2856' xml:id='l2h-
2856'
>ZIP_STORED
</tt></b></dt>
The numeric constant for an uncompressed archive member.
<dl><dt><b><tt id='l2h-
2857' xml:id='l2h-
2857'
>ZIP_DEFLATED
</tt></b></dt>
The numeric constant for the usual ZIP compression method. This
requires the zlib module. No other compression methods are
<p class=
"heading">See Also:
</p>
<dl compact=
"compact" class=
"seetitle">
<dt><em class=
"citetitle"><a href=
"http://www.pkware.com/appnote.html"
<dd>Documentation on the ZIP file format by Phil
Katz, the creator of the format and algorithms used.
</dd>
<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>
Information about the Info-ZIP project's ZIP archive
programs and development libraries.
</dd>
<p><br /></p><hr class='online-navigation'
/>
<div class='online-navigation'
>
<!--Table of Child-Links-->
<A NAME=
"CHILD_LINKS"><STRONG>Subsections
</STRONG></a>
<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>
<!--End of Table of Child-Links-->
<div class='online-navigation'
>
<table align=
"center" width=
"100%" cellpadding=
"0" cellspacing=
"2">
<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>
<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>
<span class=
"release-info">Release
2.4.2, documentation updated on
28 September
2005.
</span>
<!--End of Navigation Panel-->
See
<i><a href=
"about.html">About this document...
</a></i> for information on suggesting changes.