<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](pkgutil.xhtml "pkgutil --- Package extension utility") | - [上一頁](modules.xhtml "導入模塊") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [導入模塊](modules.xhtml) ? - $('.inline-search').show(0); | # [`zipimport`](#module-zipimport "zipimport: support for importing Python modules from ZIP archives.") --- Import modules from Zip archives - - - - - - This module adds the ability to import Python modules (`*.py`, `*.pyc`) and packages from ZIP-format archives. It is usually not needed to use the [`zipimport`](#module-zipimport "zipimport: support for importing Python modules from ZIP archives.") module explicitly; it is automatically used by the built-in [`import`](../reference/simple_stmts.xhtml#import) mechanism for [`sys.path`](sys.xhtml#sys.path "sys.path") items that are paths to ZIP archives. Typically, [`sys.path`](sys.xhtml#sys.path "sys.path") is a list of directory names as strings. This module also allows an item of [`sys.path`](sys.xhtml#sys.path "sys.path") to be a string naming a ZIP file archive. The ZIP archive can contain a subdirectory structure to support package imports, and a path within the archive can be specified to only import from a subdirectory. For example, the path `example.zip/lib/` would only import from the `lib/` subdirectory within the archive. Any files may be present in the ZIP archive, but only files `.py` and `.pyc` are available for import. ZIP import of dynamic modules (`.pyd`, `.so`) is disallowed. Note that if an archive only contains `.py` files, Python will not attempt to modify the archive by adding the corresponding `.pyc` file, meaning that if a ZIP archive doesn't contain `.pyc` files, importing may be rather slow. ZIP archives with an archive comment are currently not supported. 參見 [PKZIP Application Note](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT) \[https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT\]Phil Katz 編寫的 ZIP 文件格式文檔,此格式和使用的算法的創建者。 [**PEP 273**](https://www.python.org/dev/peps/pep-0273) \[https://www.python.org/dev/peps/pep-0273\] - Import Modules from Zip ArchivesWritten by James C. Ahlstrom, who also provided an implementation. Python 2.3 follows the specification in PEP 273, but uses an implementation written by Just van Rossum that uses the import hooks described in PEP 302. [**PEP 302**](https://www.python.org/dev/peps/pep-0302) \[https://www.python.org/dev/peps/pep-0302\] - New Import HooksThe PEP to add the import hooks that help this module work. This module defines an exception: *exception* `zipimport.``ZipImportError`Exception raised by zipimporter objects. It's a subclass of [`ImportError`](exceptions.xhtml#ImportError "ImportError"), so it can be caught as [`ImportError`](exceptions.xhtml#ImportError "ImportError"), too. ## zipimporter Objects [`zipimporter`](#zipimport.zipimporter "zipimport.zipimporter") is the class for importing ZIP files. *class* `zipimport.``zipimporter`(*archivepath*)Create a new zipimporter instance. *archivepath* must be a path to a ZIP file, or to a specific path within a ZIP file. For example, an *archivepath*of `foo/bar.zip/lib` will look for modules in the `lib` directory inside the ZIP file `foo/bar.zip` (provided that it exists). [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") is raised if *archivepath* doesn't point to a valid ZIP archive. `find_module`(*fullname*\[, *path*\])Search for a module specified by *fullname*. *fullname* must be the fully qualified (dotted) module name. It returns the zipimporter instance itself if the module was found, or [`None`](constants.xhtml#None "None") if it wasn't. The optional *path* argument is ignored---it's there for compatibility with the importer protocol. `get_code`(*fullname*)Return the code object for the specified module. Raise [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") if the module couldn't be found. `get_data`(*pathname*)Return the data associated with *pathname*. Raise [`OSError`](exceptions.xhtml#OSError "OSError") if the file wasn't found. 在 3.3 版更改: [`IOError`](exceptions.xhtml#IOError "IOError") used to be raised instead of [`OSError`](exceptions.xhtml#OSError "OSError"). `get_filename`(*fullname*)Return the value `__file__` would be set to if the specified module was imported. Raise [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") if the module couldn't be found. 3\.1 新版功能. `get_source`(*fullname*)Return the source code for the specified module. Raise [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") if the module couldn't be found, return [`None`](constants.xhtml#None "None") if the archive does contain the module, but has no source for it. `is_package`(*fullname*)Return `True` if the module specified by *fullname* is a package. Raise [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") if the module couldn't be found. `load_module`(*fullname*)Load the module specified by *fullname*. *fullname* must be the fully qualified (dotted) module name. It returns the imported module, or raises [`ZipImportError`](#zipimport.ZipImportError "zipimport.ZipImportError") if it wasn't found. `archive`The file name of the importer's associated ZIP file, without a possible subpath. `prefix`The subpath within the ZIP file where modules are searched. This is the empty string for zipimporter objects which point to the root of the ZIP file. The [`archive`](#zipimport.zipimporter.archive "zipimport.zipimporter.archive") and [`prefix`](#zipimport.zipimporter.prefix "zipimport.zipimporter.prefix") attributes, when combined with a slash, equal the original *archivepath* argument given to the [`zipimporter`](#zipimport.zipimporter "zipimport.zipimporter") constructor. ## 示例 Here is an example that imports a module from a ZIP archive - note that the [`zipimport`](#module-zipimport "zipimport: support for importing Python modules from ZIP archives.") module is not explicitly used. ``` $ unzip -l example.zip Archive: example.zip Length Date Time Name -------- ---- ---- ---- 8467 11-26-02 22:30 jwzthreading.py -------- ------- 8467 1 file $ ./python Python 2.3 (#1, Aug 1 2003, 19:54:32) >>> import sys >>> sys.path.insert(0, 'example.zip') # Add .zip file to front of path >>> import jwzthreading >>> jwzthreading.__file__ 'example.zip/jwzthreading.py' ``` ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](pkgutil.xhtml "pkgutil --- Package extension utility") | - [上一頁](modules.xhtml "導入模塊") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - [Python 標準庫](index.xhtml) ? - [導入模塊](modules.xhtml) ? - $('.inline-search').show(0); | ? [版權所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 軟件基金會是一個非盈利組織。 [請捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [發現了問題](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 創建。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看