gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

625 line
50KB

  1. <!DOCTYPE html>
  2. <html lang="en" data-content_root="../">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <meta property="og:title" content="gzip — Support for gzip files" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/gzip.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. The data compression is provided by the zlib modu..." />
  11. <meta property="og:image" content="https://docs.python.org/3/_static/og-image.png" />
  12. <meta property="og:image:alt" content="Python documentation" />
  13. <meta name="description" content="Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. The data compression is provided by the zlib modu..." />
  14. <meta property="og:image:width" content="200" />
  15. <meta property="og:image:height" content="200" />
  16. <meta name="theme-color" content="#3776ab" />
  17. <title>gzip — Support for gzip files &#8212; Python 3.12.3 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
  18. <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=80d5e7a1" />
  19. <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=bb723527" />
  20. <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=b20cc3f5" />
  21. <script src="../_static/documentation_options.js?v=2c828074"></script>
  22. <script src="../_static/doctools.js?v=888ff710"></script>
  23. <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
  24. <script src="../_static/sidebar.js"></script>
  25. <link rel="search" type="application/opensearchdescription+xml"
  26. title="Search within Python 3.12.3 documentation"
  27. href="../_static/opensearch.xml"/>
  28. <link rel="author" title="About these documents" href="../about.html" />
  29. <link rel="index" title="Index" href="../genindex.html" />
  30. <link rel="search" title="Search" href="../search.html" />
  31. <link rel="copyright" title="Copyright" href="../copyright.html" />
  32. <link rel="next" title="bz2 — Support for bzip2 compression" href="bz2.html" />
  33. <link rel="prev" title="zlib — Compression compatible with gzip" href="zlib.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/gzip.html" />
  35. <style>
  36. @media only screen {
  37. table.full-width-table {
  38. width: 100%;
  39. }
  40. }
  41. </style>
  42. <link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">
  43. <link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
  44. <script type="text/javascript" src="../_static/copybutton.js"></script>
  45. <script type="text/javascript" src="../_static/menu.js"></script>
  46. <script type="text/javascript" src="../_static/search-focus.js"></script>
  47. <script type="text/javascript" src="../_static/themetoggle.js"></script>
  48. </head>
  49. <body>
  50. <div class="mobile-nav">
  51. <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
  52. aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
  53. <nav class="nav-content" role="navigation">
  54. <label for="menuToggler" class="toggler__label">
  55. <span></span>
  56. </label>
  57. <span class="nav-items-wrapper">
  58. <a href="https://www.python.org/" class="nav-logo">
  59. <img src="../_static/py.svg" alt="Python logo"/>
  60. </a>
  61. <span class="version_switcher_placeholder"></span>
  62. <form role="search" class="search" action="../search.html" method="get">
  63. <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
  64. <path fill-rule="nonzero" fill="currentColor" 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"></path>
  65. </svg>
  66. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" />
  67. <input type="submit" value="Go"/>
  68. </form>
  69. </span>
  70. </nav>
  71. <div class="menu-wrapper">
  72. <nav class="menu" role="navigation" aria-label="main navigation">
  73. <div class="language_switcher_placeholder"></div>
  74. <label class="theme-selector-label">
  75. Theme
  76. <select class="theme-selector" oninput="activateTheme(this.value)">
  77. <option value="auto" selected>Auto</option>
  78. <option value="light">Light</option>
  79. <option value="dark">Dark</option>
  80. </select>
  81. </label>
  82. <div>
  83. <h3><a href="../contents.html">Table of Contents</a></h3>
  84. <ul>
  85. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a><ul>
  86. <li><a class="reference internal" href="#examples-of-usage">Examples of usage</a></li>
  87. <li><a class="reference internal" href="#command-line-interface">Command Line Interface</a><ul>
  88. <li><a class="reference internal" href="#command-line-options">Command line options</a></li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </li>
  93. </ul>
  94. </div>
  95. <div>
  96. <h4>Previous topic</h4>
  97. <p class="topless"><a href="zlib.html"
  98. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code> — Compression compatible with <strong class="program">gzip</strong></a></p>
  99. </div>
  100. <div>
  101. <h4>Next topic</h4>
  102. <p class="topless"><a href="bz2.html"
  103. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bz2</span></code> — Support for <strong class="program">bzip2</strong> compression</a></p>
  104. </div>
  105. <div role="note" aria-label="source link">
  106. <h3>This Page</h3>
  107. <ul class="this-page-menu">
  108. <li><a href="../bugs.html">Report a Bug</a></li>
  109. <li>
  110. <a href="https://github.com/python/cpython/blob/main/Doc/library/gzip.rst"
  111. rel="nofollow">Show Source
  112. </a>
  113. </li>
  114. </ul>
  115. </div>
  116. </nav>
  117. </div>
  118. </div>
  119. <div class="related" role="navigation" aria-label="related navigation">
  120. <h3>Navigation</h3>
  121. <ul>
  122. <li class="right" style="margin-right: 10px">
  123. <a href="../genindex.html" title="General Index"
  124. accesskey="I">index</a></li>
  125. <li class="right" >
  126. <a href="../py-modindex.html" title="Python Module Index"
  127. >modules</a> |</li>
  128. <li class="right" >
  129. <a href="bz2.html" title="bz2 — Support for bzip2 compression"
  130. accesskey="N">next</a> |</li>
  131. <li class="right" >
  132. <a href="zlib.html" title="zlib — Compression compatible with gzip"
  133. accesskey="P">previous</a> |</li>
  134. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  135. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  136. <li class="switchers">
  137. <div class="language_switcher_placeholder"></div>
  138. <div class="version_switcher_placeholder"></div>
  139. </li>
  140. <li>
  141. </li>
  142. <li id="cpython-language-and-version">
  143. <a href="../index.html">3.12.3 Documentation</a> &#187;
  144. </li>
  145. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  146. <li class="nav-item nav-item-2"><a href="archiving.html" accesskey="U">Data Compression and Archiving</a> &#187;</li>
  147. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a></li>
  148. <li class="right">
  149. <div class="inline-search" role="search">
  150. <form class="inline-search" action="../search.html" method="get">
  151. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  152. <input type="submit" value="Go" />
  153. </form>
  154. </div>
  155. |
  156. </li>
  157. <li class="right">
  158. <label class="theme-selector-label">
  159. Theme
  160. <select class="theme-selector" oninput="activateTheme(this.value)">
  161. <option value="auto" selected>Auto</option>
  162. <option value="light">Light</option>
  163. <option value="dark">Dark</option>
  164. </select>
  165. </label> |</li>
  166. </ul>
  167. </div>
  168. <div class="document">
  169. <div class="documentwrapper">
  170. <div class="bodywrapper">
  171. <div class="body" role="main">
  172. <section id="module-gzip">
  173. <span id="gzip-support-for-gzip-files"></span><h1><a class="reference internal" href="#module-gzip" title="gzip: Interfaces for gzip compression and decompression using file objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code></a> — Support for <strong class="program">gzip</strong> files<a class="headerlink" href="#module-gzip" title="Link to this heading">¶</a></h1>
  174. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/gzip.py">Lib/gzip.py</a></p>
  175. <hr class="docutils" />
  176. <p>This module provides a simple interface to compress and decompress files just
  177. like the GNU programs <strong class="program">gzip</strong> and <strong class="program">gunzip</strong> would.</p>
  178. <p>The data compression is provided by the <a class="reference internal" href="zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a> module.</p>
  179. <p>The <a class="reference internal" href="#module-gzip" title="gzip: Interfaces for gzip compression and decompression using file objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code></a> module provides the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> class, as well as the
  180. <a class="reference internal" href="#gzip.open" title="gzip.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>, <a class="reference internal" href="#gzip.compress" title="gzip.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">compress()</span></code></a> and <a class="reference internal" href="#gzip.decompress" title="gzip.decompress"><code class="xref py py-func docutils literal notranslate"><span class="pre">decompress()</span></code></a> convenience functions.
  181. The <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> class reads and writes <strong class="program">gzip</strong>-format files,
  182. automatically compressing or decompressing the data so that it looks like an
  183. ordinary <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file object</span></a>.</p>
  184. <p>Note that additional file formats which can be decompressed by the
  185. <strong class="program">gzip</strong> and <strong class="program">gunzip</strong> programs, such as those produced by
  186. <strong class="program">compress</strong> and <strong class="program">pack</strong>, are not supported by this module.</p>
  187. <p>The module defines the following items:</p>
  188. <dl class="py function">
  189. <dt class="sig sig-object py" id="gzip.open">
  190. <span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'rb'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">errors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newline</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.open" title="Link to this definition">¶</a></dt>
  191. <dd><p>Open a gzip-compressed file in binary or text mode, returning a <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file
  192. object</span></a>.</p>
  193. <p>The <em>filename</em> argument can be an actual filename (a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or
  194. <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object), or an existing file object to read from or write to.</p>
  195. <p>The <em>mode</em> argument can be any of <code class="docutils literal notranslate"><span class="pre">'r'</span></code>, <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'a'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ab'</span></code>,
  196. <code class="docutils literal notranslate"><span class="pre">'w'</span></code>, <code class="docutils literal notranslate"><span class="pre">'wb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'x'</span></code> or <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> for binary mode, or <code class="docutils literal notranslate"><span class="pre">'rt'</span></code>,
  197. <code class="docutils literal notranslate"><span class="pre">'at'</span></code>, <code class="docutils literal notranslate"><span class="pre">'wt'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'xt'</span></code> for text mode. The default is <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>.</p>
  198. <p>The <em>compresslevel</em> argument is an integer from 0 to 9, as for the
  199. <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> constructor.</p>
  200. <p>For binary mode, this function is equivalent to the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a>
  201. constructor: <code class="docutils literal notranslate"><span class="pre">GzipFile(filename,</span> <span class="pre">mode,</span> <span class="pre">compresslevel)</span></code>. In this case, the
  202. <em>encoding</em>, <em>errors</em> and <em>newline</em> arguments must not be provided.</p>
  203. <p>For text mode, a <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> object is created, and wrapped in an
  204. <a class="reference internal" href="io.html#io.TextIOWrapper" title="io.TextIOWrapper"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOWrapper</span></code></a> instance with the specified encoding, error
  205. handling behavior, and line ending(s).</p>
  206. <div class="versionchanged">
  207. <p><span class="versionmodified changed">Changed in version 3.3: </span>Added support for <em>filename</em> being a file object, support for text mode,
  208. and the <em>encoding</em>, <em>errors</em> and <em>newline</em> arguments.</p>
  209. </div>
  210. <div class="versionchanged">
  211. <p><span class="versionmodified changed">Changed in version 3.4: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> and <code class="docutils literal notranslate"><span class="pre">'xt'</span></code> modes.</p>
  212. </div>
  213. <div class="versionchanged">
  214. <p><span class="versionmodified changed">Changed in version 3.6: </span>Accepts a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>
  215. </div>
  216. </dd></dl>
  217. <dl class="py exception">
  218. <dt class="sig sig-object py" id="gzip.BadGzipFile">
  219. <em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">BadGzipFile</span></span><a class="headerlink" href="#gzip.BadGzipFile" title="Link to this definition">¶</a></dt>
  220. <dd><p>An exception raised for invalid gzip files. It inherits from <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>.
  221. <a class="reference internal" href="exceptions.html#EOFError" title="EOFError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EOFError</span></code></a> and <a class="reference internal" href="zlib.html#zlib.error" title="zlib.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">zlib.error</span></code></a> can also be raised for invalid gzip
  222. files.</p>
  223. <div class="versionadded">
  224. <p><span class="versionmodified added">New in version 3.8.</span></p>
  225. </div>
  226. </dd></dl>
  227. <dl class="py class">
  228. <dt class="sig sig-object py" id="gzip.GzipFile">
  229. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">GzipFile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fileobj</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mtime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.GzipFile" title="Link to this definition">¶</a></dt>
  230. <dd><p>Constructor for the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> class, which simulates most of the
  231. methods of a <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file object</span></a>, with the exception of the <a class="reference internal" href="io.html#io.IOBase.truncate" title="io.IOBase.truncate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">truncate()</span></code></a>
  232. method. At least one of <em>fileobj</em> and <em>filename</em> must be given a non-trivial
  233. value.</p>
  234. <p>The new class instance is based on <em>fileobj</em>, which can be a regular file, an
  235. <a class="reference internal" href="io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> object, or any other object which simulates a file. It
  236. defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, in which case <em>filename</em> is opened to provide a file
  237. object.</p>
  238. <p>When <em>fileobj</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the <em>filename</em> argument is only used to be
  239. included in the <strong class="program">gzip</strong> file header, which may include the original
  240. filename of the uncompressed file. It defaults to the filename of <em>fileobj</em>, if
  241. discernible; otherwise, it defaults to the empty string, and in this case the
  242. original filename is not included in the header.</p>
  243. <p>The <em>mode</em> argument can be any of <code class="docutils literal notranslate"><span class="pre">'r'</span></code>, <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'a'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ab'</span></code>, <code class="docutils literal notranslate"><span class="pre">'w'</span></code>,
  244. <code class="docutils literal notranslate"><span class="pre">'wb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'xb'</span></code>, depending on whether the file will be read or
  245. written. The default is the mode of <em>fileobj</em> if discernible; otherwise, the
  246. default is <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>. In future Python releases the mode of <em>fileobj</em> will
  247. not be used. It is better to always specify <em>mode</em> for writing.</p>
  248. <p>Note that the file is always opened in binary mode. To open a compressed file
  249. in text mode, use <a class="reference internal" href="#gzip.open" title="gzip.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> (or wrap your <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> with an
  250. <a class="reference internal" href="io.html#io.TextIOWrapper" title="io.TextIOWrapper"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOWrapper</span></code></a>).</p>
  251. <p>The <em>compresslevel</em> argument is an integer from <code class="docutils literal notranslate"><span class="pre">0</span></code> to <code class="docutils literal notranslate"><span class="pre">9</span></code> controlling
  252. the level of compression; <code class="docutils literal notranslate"><span class="pre">1</span></code> is fastest and produces the least
  253. compression, and <code class="docutils literal notranslate"><span class="pre">9</span></code> is slowest and produces the most compression. <code class="docutils literal notranslate"><span class="pre">0</span></code>
  254. is no compression. The default is <code class="docutils literal notranslate"><span class="pre">9</span></code>.</p>
  255. <p>The <em>mtime</em> argument is an optional numeric timestamp to be written to
  256. the last modification time field in the stream when compressing. It
  257. should only be provided in compression mode. If omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, the
  258. current time is used. See the <a class="reference internal" href="#gzip.GzipFile.mtime" title="gzip.GzipFile.mtime"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mtime</span></code></a> attribute for more details.</p>
  259. <p>Calling a <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> object’s <code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code> method does not close
  260. <em>fileobj</em>, since you might wish to append more material after the compressed
  261. data. This also allows you to pass an <a class="reference internal" href="io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> object opened for
  262. writing as <em>fileobj</em>, and retrieve the resulting memory buffer using the
  263. <a class="reference internal" href="io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> object’s <a class="reference internal" href="io.html#io.BytesIO.getvalue" title="io.BytesIO.getvalue"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getvalue()</span></code></a> method.</p>
  264. <p><a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> supports the <a class="reference internal" href="io.html#io.BufferedIOBase" title="io.BufferedIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BufferedIOBase</span></code></a> interface,
  265. including iteration and the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement. Only the
  266. <a class="reference internal" href="io.html#io.IOBase.truncate" title="io.IOBase.truncate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">truncate()</span></code></a> method isn’t implemented.</p>
  267. <p><a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> also provides the following method and attribute:</p>
  268. <dl class="py method">
  269. <dt class="sig sig-object py" id="gzip.GzipFile.peek">
  270. <span class="sig-name descname"><span class="pre">peek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.GzipFile.peek" title="Link to this definition">¶</a></dt>
  271. <dd><p>Read <em>n</em> uncompressed bytes without advancing the file position.
  272. At most one single read on the compressed stream is done to satisfy
  273. the call. The number of bytes returned may be more or less than
  274. requested.</p>
  275. <div class="admonition note">
  276. <p class="admonition-title">Note</p>
  277. <p>While calling <a class="reference internal" href="#gzip.GzipFile.peek" title="gzip.GzipFile.peek"><code class="xref py py-meth docutils literal notranslate"><span class="pre">peek()</span></code></a> does not change the file position of
  278. the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a>, it may change the position of the underlying
  279. file object (e.g. if the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> was constructed with the
  280. <em>fileobj</em> parameter).</p>
  281. </div>
  282. <div class="versionadded">
  283. <p><span class="versionmodified added">New in version 3.2.</span></p>
  284. </div>
  285. </dd></dl>
  286. <dl class="py attribute">
  287. <dt class="sig sig-object py" id="gzip.GzipFile.mtime">
  288. <span class="sig-name descname"><span class="pre">mtime</span></span><a class="headerlink" href="#gzip.GzipFile.mtime" title="Link to this definition">¶</a></dt>
  289. <dd><p>When decompressing, the value of the last modification time field in
  290. the most recently read header may be read from this attribute, as an
  291. integer. The initial value before reading any headers is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
  292. <p>All <strong class="program">gzip</strong> compressed streams are required to contain this
  293. timestamp field. Some programs, such as <strong class="program">gunzip</strong>, make use
  294. of the timestamp. The format is the same as the return value of
  295. <a class="reference internal" href="time.html#time.time" title="time.time"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.time()</span></code></a> and the <a class="reference internal" href="os.html#os.stat_result.st_mtime" title="os.stat_result.st_mtime"><code class="xref py py-attr docutils literal notranslate"><span class="pre">st_mtime</span></code></a> attribute of
  296. the object returned by <a class="reference internal" href="os.html#os.stat" title="os.stat"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.stat()</span></code></a>.</p>
  297. </dd></dl>
  298. <dl class="py attribute">
  299. <dt class="sig sig-object py" id="gzip.GzipFile.name">
  300. <span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#gzip.GzipFile.name" title="Link to this definition">¶</a></dt>
  301. <dd><p>The path to the gzip file on disk, as a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>.
  302. Equivalent to the output of <a class="reference internal" href="os.html#os.fspath" title="os.fspath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fspath()</span></code></a> on the original input path,
  303. with no other normalization, resolution or expansion.</p>
  304. </dd></dl>
  305. <div class="versionchanged">
  306. <p><span class="versionmodified changed">Changed in version 3.1: </span>Support for the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement was added, along with the
  307. <em>mtime</em> constructor argument and <a class="reference internal" href="#gzip.GzipFile.mtime" title="gzip.GzipFile.mtime"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mtime</span></code></a> attribute.</p>
  308. </div>
  309. <div class="versionchanged">
  310. <p><span class="versionmodified changed">Changed in version 3.2: </span>Support for zero-padded and unseekable files was added.</p>
  311. </div>
  312. <div class="versionchanged">
  313. <p><span class="versionmodified changed">Changed in version 3.3: </span>The <a class="reference internal" href="io.html#io.BufferedIOBase.read1" title="io.BufferedIOBase.read1"><code class="xref py py-meth docutils literal notranslate"><span class="pre">io.BufferedIOBase.read1()</span></code></a> method is now implemented.</p>
  314. </div>
  315. <div class="versionchanged">
  316. <p><span class="versionmodified changed">Changed in version 3.4: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">'x'</span></code> and <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> modes.</p>
  317. </div>
  318. <div class="versionchanged">
  319. <p><span class="versionmodified changed">Changed in version 3.5: </span>Added support for writing arbitrary
  320. <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a>.
  321. The <a class="reference internal" href="io.html#io.BufferedIOBase.read" title="io.BufferedIOBase.read"><code class="xref py py-meth docutils literal notranslate"><span class="pre">read()</span></code></a> method now accepts an argument of
  322. <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
  323. </div>
  324. <div class="versionchanged">
  325. <p><span class="versionmodified changed">Changed in version 3.6: </span>Accepts a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>
  326. </div>
  327. <div class="versionchanged">
  328. <p><span class="versionmodified changed">Changed in version 3.12: </span>Remove the <code class="docutils literal notranslate"><span class="pre">filename</span></code> attribute, use the <a class="reference internal" href="#gzip.GzipFile.name" title="gzip.GzipFile.name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code></a>
  329. attribute instead.</p>
  330. </div>
  331. <div class="deprecated">
  332. <p><span class="versionmodified deprecated">Deprecated since version 3.9: </span>Opening <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> for writing without specifying the <em>mode</em>
  333. argument is deprecated.</p>
  334. </div>
  335. </dd></dl>
  336. <dl class="py function">
  337. <dt class="sig sig-object py" id="gzip.compress">
  338. <span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">compress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">9</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mtime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.compress" title="Link to this definition">¶</a></dt>
  339. <dd><p>Compress the <em>data</em>, returning a <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object containing
  340. the compressed data. <em>compresslevel</em> and <em>mtime</em> have the same meaning as in
  341. the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> constructor above. When <em>mtime</em> is set to <code class="docutils literal notranslate"><span class="pre">0</span></code>, this
  342. function is equivalent to <a class="reference internal" href="zlib.html#zlib.compress" title="zlib.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">zlib.compress()</span></code></a> with <em>wbits</em> set to <code class="docutils literal notranslate"><span class="pre">31</span></code>.
  343. The zlib function is faster.</p>
  344. <div class="versionadded">
  345. <p><span class="versionmodified added">New in version 3.2.</span></p>
  346. </div>
  347. <div class="versionchanged">
  348. <p><span class="versionmodified changed">Changed in version 3.8: </span>Added the <em>mtime</em> parameter for reproducible output.</p>
  349. </div>
  350. <div class="versionchanged">
  351. <p><span class="versionmodified changed">Changed in version 3.11: </span>Speed is improved by compressing all data at once instead of in a
  352. streamed fashion. Calls with <em>mtime</em> set to <code class="docutils literal notranslate"><span class="pre">0</span></code> are delegated to
  353. <a class="reference internal" href="zlib.html#zlib.compress" title="zlib.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">zlib.compress()</span></code></a> for better speed.</p>
  354. </div>
  355. </dd></dl>
  356. <dl class="py function">
  357. <dt class="sig sig-object py" id="gzip.decompress">
  358. <span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">decompress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.decompress" title="Link to this definition">¶</a></dt>
  359. <dd><p>Decompress the <em>data</em>, returning a <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object containing the
  360. uncompressed data. This function is capable of decompressing multi-member
  361. gzip data (multiple gzip blocks concatenated together). When the data is
  362. certain to contain only one member the <a class="reference internal" href="zlib.html#zlib.decompress" title="zlib.decompress"><code class="xref py py-func docutils literal notranslate"><span class="pre">zlib.decompress()</span></code></a> function with
  363. <em>wbits</em> set to 31 is faster.</p>
  364. <div class="versionadded">
  365. <p><span class="versionmodified added">New in version 3.2.</span></p>
  366. </div>
  367. <div class="versionchanged">
  368. <p><span class="versionmodified changed">Changed in version 3.11: </span>Speed is improved by decompressing members at once in memory instead of in
  369. a streamed fashion.</p>
  370. </div>
  371. </dd></dl>
  372. <section id="examples-of-usage">
  373. <span id="gzip-usage-examples"></span><h2>Examples of usage<a class="headerlink" href="#examples-of-usage" title="Link to this heading">¶</a></h2>
  374. <p>Example of how to read a compressed file:</p>
  375. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gzip</span>
  376. <span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;/home/joe/file.txt.gz&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
  377. <span class="n">file_content</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
  378. </pre></div>
  379. </div>
  380. <p>Example of how to create a compressed GZIP file:</p>
  381. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gzip</span>
  382. <span class="n">content</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">&quot;Lots of content here&quot;</span>
  383. <span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;/home/joe/file.txt.gz&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
  384. <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">content</span><span class="p">)</span>
  385. </pre></div>
  386. </div>
  387. <p>Example of how to GZIP compress an existing file:</p>
  388. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gzip</span>
  389. <span class="kn">import</span> <span class="nn">shutil</span>
  390. <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">&#39;/home/joe/file.txt&#39;</span><span class="p">,</span> <span class="s1">&#39;rb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_in</span><span class="p">:</span>
  391. <span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">&#39;/home/joe/file.txt.gz&#39;</span><span class="p">,</span> <span class="s1">&#39;wb&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_out</span><span class="p">:</span>
  392. <span class="n">shutil</span><span class="o">.</span><span class="n">copyfileobj</span><span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">)</span>
  393. </pre></div>
  394. </div>
  395. <p>Example of how to GZIP compress a binary string:</p>
  396. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">gzip</span>
  397. <span class="n">s_in</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">&quot;Lots of content here&quot;</span>
  398. <span class="n">s_out</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">compress</span><span class="p">(</span><span class="n">s_in</span><span class="p">)</span>
  399. </pre></div>
  400. </div>
  401. <div class="admonition seealso">
  402. <p class="admonition-title">See also</p>
  403. <dl class="simple">
  404. <dt>Module <a class="reference internal" href="zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a></dt><dd><p>The basic data compression module needed to support the <strong class="program">gzip</strong> file
  405. format.</p>
  406. </dd>
  407. </dl>
  408. </div>
  409. </section>
  410. <section id="command-line-interface">
  411. <span id="gzip-cli"></span><h2>Command Line Interface<a class="headerlink" href="#command-line-interface" title="Link to this heading">¶</a></h2>
  412. <p>The <a class="reference internal" href="#module-gzip" title="gzip: Interfaces for gzip compression and decompression using file objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code></a> module provides a simple command line interface to compress or
  413. decompress files.</p>
  414. <p>Once executed the <a class="reference internal" href="#module-gzip" title="gzip: Interfaces for gzip compression and decompression using file objects."><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code></a> module keeps the input file(s).</p>
  415. <div class="versionchanged">
  416. <p><span class="versionmodified changed">Changed in version 3.8: </span>Add a new command line interface with a usage.
  417. By default, when you will execute the CLI, the default compression level is 6.</p>
  418. </div>
  419. <section id="command-line-options">
  420. <h3>Command line options<a class="headerlink" href="#command-line-options" title="Link to this heading">¶</a></h3>
  421. <dl class="std option">
  422. <dt class="sig sig-object std" id="cmdoption-gzip-arg-file">
  423. <span class="sig-name descname"><span class="pre">file</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-arg-file" title="Link to this definition">¶</a></dt>
  424. <dd><p>If <em>file</em> is not specified, read from <a class="reference internal" href="sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>.</p>
  425. </dd></dl>
  426. <dl class="std option">
  427. <dt class="sig sig-object std" id="cmdoption-gzip-fast">
  428. <span class="sig-name descname"><span class="pre">--fast</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-fast" title="Link to this definition">¶</a></dt>
  429. <dd><p>Indicates the fastest compression method (less compression).</p>
  430. </dd></dl>
  431. <dl class="std option">
  432. <dt class="sig sig-object std" id="cmdoption-gzip-best">
  433. <span class="sig-name descname"><span class="pre">--best</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-best" title="Link to this definition">¶</a></dt>
  434. <dd><p>Indicates the slowest compression method (best compression).</p>
  435. </dd></dl>
  436. <dl class="std option">
  437. <dt class="sig sig-object std" id="cmdoption-gzip-d">
  438. <span id="cmdoption-gzip-decompress"></span><span class="sig-name descname"><span class="pre">-d</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--decompress</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-d" title="Link to this definition">¶</a></dt>
  439. <dd><p>Decompress the given file.</p>
  440. </dd></dl>
  441. <dl class="std option">
  442. <dt class="sig sig-object std" id="cmdoption-gzip-h">
  443. <span id="cmdoption-gzip-help"></span><span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-h" title="Link to this definition">¶</a></dt>
  444. <dd><p>Show the help message.</p>
  445. </dd></dl>
  446. </section>
  447. </section>
  448. </section>
  449. <div class="clearer"></div>
  450. </div>
  451. </div>
  452. </div>
  453. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  454. <div class="sphinxsidebarwrapper">
  455. <div>
  456. <h3><a href="../contents.html">Table of Contents</a></h3>
  457. <ul>
  458. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a><ul>
  459. <li><a class="reference internal" href="#examples-of-usage">Examples of usage</a></li>
  460. <li><a class="reference internal" href="#command-line-interface">Command Line Interface</a><ul>
  461. <li><a class="reference internal" href="#command-line-options">Command line options</a></li>
  462. </ul>
  463. </li>
  464. </ul>
  465. </li>
  466. </ul>
  467. </div>
  468. <div>
  469. <h4>Previous topic</h4>
  470. <p class="topless"><a href="zlib.html"
  471. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code> — Compression compatible with <strong class="program">gzip</strong></a></p>
  472. </div>
  473. <div>
  474. <h4>Next topic</h4>
  475. <p class="topless"><a href="bz2.html"
  476. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bz2</span></code> — Support for <strong class="program">bzip2</strong> compression</a></p>
  477. </div>
  478. <div role="note" aria-label="source link">
  479. <h3>This Page</h3>
  480. <ul class="this-page-menu">
  481. <li><a href="../bugs.html">Report a Bug</a></li>
  482. <li>
  483. <a href="https://github.com/python/cpython/blob/main/Doc/library/gzip.rst"
  484. rel="nofollow">Show Source
  485. </a>
  486. </li>
  487. </ul>
  488. </div>
  489. </div>
  490. <div id="sidebarbutton" title="Collapse sidebar">
  491. <span>«</span>
  492. </div>
  493. </div>
  494. <div class="clearer"></div>
  495. </div>
  496. <div class="related" role="navigation" aria-label="related navigation">
  497. <h3>Navigation</h3>
  498. <ul>
  499. <li class="right" style="margin-right: 10px">
  500. <a href="../genindex.html" title="General Index"
  501. >index</a></li>
  502. <li class="right" >
  503. <a href="../py-modindex.html" title="Python Module Index"
  504. >modules</a> |</li>
  505. <li class="right" >
  506. <a href="bz2.html" title="bz2 — Support for bzip2 compression"
  507. >next</a> |</li>
  508. <li class="right" >
  509. <a href="zlib.html" title="zlib — Compression compatible with gzip"
  510. >previous</a> |</li>
  511. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  512. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  513. <li class="switchers">
  514. <div class="language_switcher_placeholder"></div>
  515. <div class="version_switcher_placeholder"></div>
  516. </li>
  517. <li>
  518. </li>
  519. <li id="cpython-language-and-version">
  520. <a href="../index.html">3.12.3 Documentation</a> &#187;
  521. </li>
  522. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  523. <li class="nav-item nav-item-2"><a href="archiving.html" >Data Compression and Archiving</a> &#187;</li>
  524. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a></li>
  525. <li class="right">
  526. <div class="inline-search" role="search">
  527. <form class="inline-search" action="../search.html" method="get">
  528. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  529. <input type="submit" value="Go" />
  530. </form>
  531. </div>
  532. |
  533. </li>
  534. <li class="right">
  535. <label class="theme-selector-label">
  536. Theme
  537. <select class="theme-selector" oninput="activateTheme(this.value)">
  538. <option value="auto" selected>Auto</option>
  539. <option value="light">Light</option>
  540. <option value="dark">Dark</option>
  541. </select>
  542. </label> |</li>
  543. </ul>
  544. </div>
  545. <div class="footer">
  546. &copy;
  547. <a href="../copyright.html">
  548. Copyright
  549. </a>
  550. 2001-2024, Python Software Foundation.
  551. <br />
  552. This page is licensed under the Python Software Foundation License Version 2.
  553. <br />
  554. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  555. <br />
  556. See <a href="/license.html">History and License</a> for more information.<br />
  557. <br />
  558. The Python Software Foundation is a non-profit corporation.
  559. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  560. <br />
  561. <br />
  562. Last updated on Apr 09, 2024 (13:47 UTC).
  563. <a href="/bugs.html">Found a bug</a>?
  564. <br />
  565. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  566. </div>
  567. </body>
  568. </html>
上海开阖软件有限公司 沪ICP备12045867号-1