📄 pyzipfile-objects.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>7.16.2 PyZipFile Objects </title>
<META NAME="description" CONTENT="7.16.2 PyZipFile Objects ">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html">
<LINK REL="previous" href="zipfile-objects.html" tppabs="http://www.python.org/doc/current/lib/zipfile-objects.html">
<LINK REL="up" href="module-zipfile.html" tppabs="http://www.python.org/doc/current/lib/module-zipfile.html">
<LINK REL="next" href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="zipfile-objects.html" tppabs="http://www.python.org/doc/current/lib/zipfile-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="module-zipfile.html" tppabs="http://www.python.org/doc/current/lib/module-zipfile.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="zipfile-objects.html" tppabs="http://www.python.org/doc/current/lib/zipfile-objects.html">7.16.1 ZipFile Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-zipfile.html" tppabs="http://www.python.org/doc/current/lib/module-zipfile.html">7.16 zipfile </A>
<b class="navlabel">Next:</b> <a class="sectref" href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html">7.16.3 ZipInfo Objects</A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H2>
<BR>
7.16.2 PyZipFile Objects
</H2>
<P>
The <tt class="class">PyZipFile</tt> constructor takes the same parameters as the
<tt class="class">ZipFile</tt> constructor. Instances have one method in addition to
those of <tt class="class">ZipFile</tt> objects.
<P>
<dl><dt><b><a name='l2h-1774'><tt class='method'>writepy</tt></a></b> (<var>pathname</var><big>[</big><var>, basename</var><big>]</big>)
<dd>
Search for files <span class="file">*.py</span> and add the corresponding file to the
archive. The corresponding file is a <span class="file">*.pyo</span> file if
available, else a <span class="file">*.pyc</span> file, compiling if necessary. If the
pathname is a file, the filename must end with <span class="file">.py</span>, and just
the (corresponding <span class="file">*.py[co]</span>) file is added at the top level
(no path information). If it is a directory, and the directory is
not a package directory, then all the files <span class="file">*.py[co]</span> are
added at the top level. If the directory is a package directory,
then all <span class="file">*.py[oc]</span> are added under the package name as a file
path, and if any subdirectories are package directories, all of
these are added recursively. <var>basename</var> is intended for
internal use only. The <tt class="method">writepy()</tt> method makes archives
with file names like this:
<P>
<dl><dd><pre class="verbatim">
string.pyc # Top level name
test/__init__.pyc # Package directory
test/testall.pyc # Module test.testall
test/bogus/__init__.pyc # Subpackage directory
test/bogus/myfile.pyc # Submodule test.bogus.myfile
</pre></dl>
</dl>
<P>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="zipfile-objects.html" tppabs="http://www.python.org/doc/current/lib/zipfile-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="module-zipfile.html" tppabs="http://www.python.org/doc/current/lib/module-zipfile.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="zipfile-objects.html" tppabs="http://www.python.org/doc/current/lib/zipfile-objects.html">7.16.1 ZipFile Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" href="module-zipfile.html" tppabs="http://www.python.org/doc/current/lib/module-zipfile.html">7.16 zipfile </A>
<b class="navlabel">Next:</b> <a class="sectref" href="zipinfo-objects.html" tppabs="http://www.python.org/doc/current/lib/zipinfo-objects.html">7.16.3 ZipInfo Objects</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -