增加python文档
This commit is contained in:
390
web/python-docs/library/zipimport.html
Normal file
390
web/python-docs/library/zipimport.html
Normal file
@@ -0,0 +1,390 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
|
||||
<head>
|
||||
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||||
|
||||
<title>zipimport --- 从 Zip 存档中导入模块 — Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<script src="../_static/translations.js"></script>
|
||||
|
||||
<script src="../_static/sidebar.js"></script>
|
||||
|
||||
<link rel="search" type="application/opensearchdescription+xml"
|
||||
title="在 Python 3.8.20 文档 中搜索"
|
||||
href="../_static/opensearch.xml"/>
|
||||
<link rel="author" title="关于这些文档" href="../about.html" />
|
||||
<link rel="index" title="索引" href="../genindex.html" />
|
||||
<link rel="search" title="搜索" href="../search.html" />
|
||||
<link rel="copyright" title="版权所有" href="../copyright.html" />
|
||||
<link rel="next" title="pkgutil --- 包扩展工具" href="pkgutil.html" />
|
||||
<link rel="prev" title="导入模块" href="modules.html" />
|
||||
<link rel="canonical" href="https://docs.python.org/3/library/zipimport.html" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
@media only screen {
|
||||
table.full-width-table {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
|
||||
<script type="text/javascript" src="../_static/copybutton.js"></script>
|
||||
<script type="text/javascript" src="../_static/menu.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="mobile-nav">
|
||||
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
|
||||
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
|
||||
<label for="menuToggler" class="toggler__label">
|
||||
<span></span>
|
||||
</label>
|
||||
<nav class="nav-content" role="navigation">
|
||||
<a href="https://www.python.org/" class="nav-logo">
|
||||
<img src="../_static/py.svg" alt="Logo"/>
|
||||
</a>
|
||||
<div class="version_switcher_placeholder"></div>
|
||||
<form role="search" class="search" action="../search.html" method="get">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
|
||||
<path fill-rule="nonzero"
|
||||
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
|
||||
</svg>
|
||||
<input type="text" name="q" aria-label="快速搜索"/>
|
||||
<input type="submit" value="转向"/>
|
||||
</form>
|
||||
</nav>
|
||||
<div class="menu-wrapper">
|
||||
<nav class="menu" role="navigation" aria-label="main navigation">
|
||||
<div class="language_switcher_placeholder"></div>
|
||||
<h3><a href="../contents.html">目录</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipimport</span></code> --- 从 Zip 存档中导入模块</a><ul>
|
||||
<li><a class="reference internal" href="#zipimporter-objects">zipimporter 对象</a></li>
|
||||
<li><a class="reference internal" href="#examples">例子</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>上一个主题</h4>
|
||||
<p class="topless"><a href="modules.html"
|
||||
title="上一章">导入模块</a></p>
|
||||
<h4>下一个主题</h4>
|
||||
<p class="topless"><a href="pkgutil.html"
|
||||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pkgutil</span></code> --- 包扩展工具</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<h3>本页</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||||
<li>
|
||||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/zipimport.rst"
|
||||
rel="nofollow">显示源代码
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
|
||||
这个文档所针对的是一个已不再受支持的 Python 旧版本。
|
||||
你应当升级版本,并阅读
|
||||
<a href="/3/library/zipimport.html"> Python 当前稳定版本的文档</a>.
|
||||
</div>
|
||||
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>导航</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="总目录"
|
||||
accesskey="I">索引</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python 模块索引"
|
||||
>模块</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="pkgutil.html" title="pkgutil --- 包扩展工具"
|
||||
accesskey="N">下一页</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="modules.html" title="导入模块"
|
||||
accesskey="P">上一页</a> |</li>
|
||||
|
||||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||||
<li class="switchers">
|
||||
<div class="language_switcher_placeholder"></div>
|
||||
<div class="version_switcher_placeholder"></div>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
</li>
|
||||
<li id="cpython-language-and-version">
|
||||
<a href="../index.html">3.8.20 Documentation</a> »
|
||||
</li>
|
||||
|
||||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||||
<li class="nav-item nav-item-2"><a href="modules.html" accesskey="U">导入模块</a> »</li>
|
||||
<li class="right">
|
||||
|
||||
|
||||
<div class="inline-search" role="search">
|
||||
<form class="inline-search" action="../search.html" method="get">
|
||||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||||
<input type="submit" value="转向" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<section id="module-zipimport">
|
||||
<span id="zipimport-import-modules-from-zip-archives"></span><h1><a class="reference internal" href="#module-zipimport" title="zipimport: Support for importing Python modules from ZIP archives."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipimport</span></code></a> --- 从 Zip 存档中导入模块<a class="headerlink" href="#module-zipimport" title="永久链接至标题">¶</a></h1>
|
||||
<p><strong>源代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.8/Lib/zipimport.py">Lib/zipimport.py</a></p>
|
||||
<hr class="docutils" />
|
||||
<p>此模块添加了从 ZIP 格式档案中导入 Python 模块( <code class="file docutils literal notranslate"><span class="pre">*.py</span></code> , <code class="file docutils literal notranslate"><span class="pre">*.pyc</span></code> )和包的能力。通常不需要明确地使用 <a class="reference internal" href="#module-zipimport" title="zipimport: Support for importing Python modules from ZIP archives."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipimport</span></code></a> 模块,内置的 <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> 机制会自动将此模块用于 ZIP 档案路径的 <a class="reference internal" href="sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> 项目上。</p>
|
||||
<p>通常, <a class="reference internal" href="sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> 是字符串的目录名称列表。此模块同样允许 <a class="reference internal" href="sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> 的一项成为命名 ZIP 文件档案的字符串。 ZIP 档案可以容纳子目录结构去支持包的导入,并且可以将归档文件中的路径指定为仅从子目录导入。比如说,路径 <code class="file docutils literal notranslate"><span class="pre">example.zip/lib/</span></code> 将只会从档案中的 <code class="file docutils literal notranslate"><span class="pre">lib/</span></code> 子目录导入。</p>
|
||||
<p>任何文件都可以存在于 ZIP档案之中,但是只有 <code class="file docutils literal notranslate"><span class="pre">.py</span></code> 和 <code class="file docutils literal notranslate"><span class="pre">.pyc</span></code> 文件是能够导入的。不允许导入 ZIP 中的动态模组( <code class="file docutils literal notranslate"><span class="pre">.pyd</span></code> , <code class="file docutils literal notranslate"><span class="pre">.so</span></code> )。请注意,如果档案中只包含 <code class="file docutils literal notranslate"><span class="pre">.py</span></code> 文件, Python不会尝试通过添加对应的 <code class="file docutils literal notranslate"><span class="pre">.pyc</span></code> 文件修改档案,意思是如果 ZIP 档案不包含 <code class="file docutils literal notranslate"><span class="pre">.pyc</span></code> 文件,导入或许会变慢。</p>
|
||||
<div class="versionchanged">
|
||||
<p><span class="versionmodified changed">在 3.8 版更改: </span>以前,不支持带有档案注释的 ZIP 档案。</p>
|
||||
</div>
|
||||
<div class="admonition seealso">
|
||||
<p class="admonition-title">参见</p>
|
||||
<dl class="simple">
|
||||
<dt><a class="reference external" href="https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT">PKZIP Application Note</a></dt><dd><p>Phil Katz 编写的 ZIP 文件格式文档,此格式和使用的算法的创建者。</p>
|
||||
</dd>
|
||||
<dt><span class="target" id="index-8"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0273"><strong>PEP 273</strong></a> - 从ZIP压缩包导入模块</dt><dd><p>由 James C. Ahlstrom 编写,他也提供了实现。 Python 2.3 遵循 <span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0273"><strong>PEP 273</strong></a> 的规范,但是使用 Just van Rossum 编写的使用了 <span class="target" id="index-10"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> 中描述的导入钩的实现。</p>
|
||||
</dd>
|
||||
<dt><span class="target" id="index-11"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> - 新导入钩</dt><dd><p>PEP 添加导入钩来有助于模块运作。</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<p>此模块定义了一个异常:</p>
|
||||
<dl class="exception">
|
||||
<dt id="zipimport.ZipImportError">
|
||||
<em class="property">exception </em><code class="sig-prename descclassname">zipimport.</code><code class="sig-name descname">ZipImportError</code><a class="headerlink" href="#zipimport.ZipImportError" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>异常由 zipimporter 对象引发。这是 <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> 的子类,因此,也可以捕获为 <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ImportError</span></code></a> 。</p>
|
||||
</dd></dl>
|
||||
|
||||
<section id="zipimporter-objects">
|
||||
<span id="id1"></span><h2>zipimporter 对象<a class="headerlink" href="#zipimporter-objects" title="永久链接至标题">¶</a></h2>
|
||||
<p><a class="reference internal" href="#zipimport.zipimporter" title="zipimport.zipimporter"><code class="xref py py-class docutils literal notranslate"><span class="pre">zipimporter</span></code></a> 是用于导入 ZIP 文件的类。</p>
|
||||
<dl class="class">
|
||||
<dt id="zipimport.zipimporter">
|
||||
<em class="property">class </em><code class="sig-prename descclassname">zipimport.</code><code class="sig-name descname">zipimporter</code><span class="sig-paren">(</span><em class="sig-param">archivepath</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>创建新的 zipimporter 实例。 <em>archivepath</em> 必须是指向 ZIP 文件的路径,或者 ZIP 文件中的特定路径。例如, <code class="file docutils literal notranslate"><span class="pre">foo/bar.zip/lib</span></code> 的 <em>archivepath</em> 将在 ZIP 文件 <code class="file docutils literal notranslate"><span class="pre">foo/bar.zip</span></code> 中的 <code class="file docutils literal notranslate"><span class="pre">lib</span></code> 目录中查找模块(只要它存在)。</p>
|
||||
<p>如果 <em>archivepath</em> 没有指向一个有效的 ZIP 档案,引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> 。</p>
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.find_module">
|
||||
<code class="sig-name descname">find_module</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="optional">[</span>, <em class="sig-param">path</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.find_module" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>搜索由 <em>fullname</em> 指定的模块。 <em>fullname</em> 必须是完全合格的(点分的)模块名。它返回 zipimporter 实例本身如果模块被找到,或者返回 <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> 如果没找到指定模块。可选的 <em>path</em> 被忽略,这是为了与导入器协议兼容。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.get_code">
|
||||
<code class="sig-name descname">get_code</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.get_code" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>返回指定模块的代码对象。如果不能找到模块会引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> 错误。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.get_data">
|
||||
<code class="sig-name descname">get_data</code><span class="sig-paren">(</span><em class="sig-param">pathname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.get_data" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>返回与 <em>pathname</em> 相关联的数据。如果不能找到文件则引发 <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> 错误。</p>
|
||||
<div class="versionchanged">
|
||||
<p><span class="versionmodified changed">在 3.3 版更改: </span>曾经是 <a class="reference internal" href="exceptions.html#IOError" title="IOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IOError</span></code></a> 被引发而不是 <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> 。</p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.get_filename">
|
||||
<code class="sig-name descname">get_filename</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.get_filename" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>如果导入了指定的模块 <code class="docutils literal notranslate"><span class="pre">__file__</span></code> ,则返回为该模块设置的值。如果未找到模块则引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> 错误。</p>
|
||||
<div class="versionadded">
|
||||
<p><span class="versionmodified added">3.1 新版功能.</span></p>
|
||||
</div>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.get_source">
|
||||
<code class="sig-name descname">get_source</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.get_source" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>返回指定模块的源代码。如果没有找到模块则引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> ,如果档案包含模块但是没有源代码,返回 <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a> 。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.is_package">
|
||||
<code class="sig-name descname">is_package</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.is_package" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>如果由 <em>fullname</em> 指定的模块是一个包则返回 <code class="docutils literal notranslate"><span class="pre">True</span></code> 。如果不能找到模块则引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> 错误。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="zipimport.zipimporter.load_module">
|
||||
<code class="sig-name descname">load_module</code><span class="sig-paren">(</span><em class="sig-param">fullname</em><span class="sig-paren">)</span><a class="headerlink" href="#zipimport.zipimporter.load_module" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>加载由 <em>fullname</em> 指定的模块。 <em>fullname</em> 必须是完全限定的(点分的)模块名。它返回已加载模块,或者当找不到模块时引发 <a class="reference internal" href="#zipimport.ZipImportError" title="zipimport.ZipImportError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ZipImportError</span></code></a> 错误。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
<dt id="zipimport.zipimporter.archive">
|
||||
<code class="sig-name descname">archive</code><a class="headerlink" href="#zipimport.zipimporter.archive" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>导入器关联的 ZIP 文件的文件名,没有可能的子路径。</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="attribute">
|
||||
<dt id="zipimport.zipimporter.prefix">
|
||||
<code class="sig-name descname">prefix</code><a class="headerlink" href="#zipimport.zipimporter.prefix" title="永久链接至目标">¶</a></dt>
|
||||
<dd><p>ZIP 文件中搜索的模块的子路径。这是一个指向 ZIP 文件根目录的 zipimporter 对象的空字符串。</p>
|
||||
</dd></dl>
|
||||
|
||||
<p>当与斜杠结合使用时, <a class="reference internal" href="#zipimport.zipimporter.archive" title="zipimport.zipimporter.archive"><code class="xref py py-attr docutils literal notranslate"><span class="pre">archive</span></code></a> 和 <a class="reference internal" href="#zipimport.zipimporter.prefix" title="zipimport.zipimporter.prefix"><code class="xref py py-attr docutils literal notranslate"><span class="pre">prefix</span></code></a> 属性等价于赋予 <a class="reference internal" href="#zipimport.zipimporter" title="zipimport.zipimporter"><code class="xref py py-class docutils literal notranslate"><span class="pre">zipimporter</span></code></a> 构造器的原始 <em>archivepath</em> 参数。</p>
|
||||
</dd></dl>
|
||||
|
||||
</section>
|
||||
<section id="examples">
|
||||
<span id="zipimport-examples"></span><h2>例子<a class="headerlink" href="#examples" title="永久链接至标题">¶</a></h2>
|
||||
<p>这是一个从 ZIP 档案中导入模块的例子 - 请注意 <a class="reference internal" href="#module-zipimport" title="zipimport: Support for importing Python modules from ZIP archives."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipimport</span></code></a> 模块不需要明确地使用。</p>
|
||||
<div class="highlight-shell-session notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>unzip<span class="w"> </span>-l<span class="w"> </span>example.zip
|
||||
<span class="go">Archive: example.zip</span>
|
||||
<span class="go"> Length Date Time Name</span>
|
||||
<span class="go"> -------- ---- ---- ----</span>
|
||||
<span class="go"> 8467 11-26-02 22:30 jwzthreading.py</span>
|
||||
<span class="go"> -------- -------</span>
|
||||
<span class="go"> 8467 1 file</span>
|
||||
<span class="gp">$ </span>./python
|
||||
<span class="go">Python 2.3 (#1, Aug 1 2003, 19:54:32)</span>
|
||||
<span class="go">>>> import sys</span>
|
||||
<span class="go">>>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path</span>
|
||||
<span class="go">>>> import jwzthreading</span>
|
||||
<span class="go">>>> jwzthreading.__file__</span>
|
||||
<span class="go">'example.zip/jwzthreading.py'</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="../contents.html">目录</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zipimport</span></code> --- 从 Zip 存档中导入模块</a><ul>
|
||||
<li><a class="reference internal" href="#zipimporter-objects">zipimporter 对象</a></li>
|
||||
<li><a class="reference internal" href="#examples">例子</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h4>上一个主题</h4>
|
||||
<p class="topless"><a href="modules.html"
|
||||
title="上一章">导入模块</a></p>
|
||||
<h4>下一个主题</h4>
|
||||
<p class="topless"><a href="pkgutil.html"
|
||||
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pkgutil</span></code> --- 包扩展工具</a></p>
|
||||
<div role="note" aria-label="source link">
|
||||
<h3>本页</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="../bugs.html">报告 Bug</a></li>
|
||||
<li>
|
||||
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/zipimport.rst"
|
||||
rel="nofollow">显示源代码
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>导航</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../genindex.html" title="总目录"
|
||||
>索引</a></li>
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python 模块索引"
|
||||
>模块</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="pkgutil.html" title="pkgutil --- 包扩展工具"
|
||||
>下一页</a> |</li>
|
||||
<li class="right" >
|
||||
<a href="modules.html" title="导入模块"
|
||||
>上一页</a> |</li>
|
||||
|
||||
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
|
||||
<li><a href="https://www.python.org/">Python</a> »</li>
|
||||
<li class="switchers">
|
||||
<div class="language_switcher_placeholder"></div>
|
||||
<div class="version_switcher_placeholder"></div>
|
||||
</li>
|
||||
<li>
|
||||
|
||||
</li>
|
||||
<li id="cpython-language-and-version">
|
||||
<a href="../index.html">3.8.20 Documentation</a> »
|
||||
</li>
|
||||
|
||||
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> »</li>
|
||||
<li class="nav-item nav-item-2"><a href="modules.html" >导入模块</a> »</li>
|
||||
<li class="right">
|
||||
|
||||
|
||||
<div class="inline-search" role="search">
|
||||
<form class="inline-search" action="../search.html" method="get">
|
||||
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
|
||||
<input type="submit" value="转向" />
|
||||
<input type="hidden" name="check_keywords" value="yes" />
|
||||
<input type="hidden" name="area" value="default" />
|
||||
</form>
|
||||
</div>
|
||||
|
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
|
||||
<br />
|
||||
This page is licensed under the Python Software Foundation License Version 2.
|
||||
<br />
|
||||
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
|
||||
<br />
|
||||
|
||||
<br />
|
||||
|
||||
The Python Software Foundation is a non-profit corporation.
|
||||
<a href="https://www.python.org/psf/donations/">Please donate.</a>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
最后更新于 12月 09, 2024.
|
||||
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
|
||||
<br />
|
||||
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user