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 satır
51KB

  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="base64 — Base16, Base32, Base64, Base85 Data Encodings" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/base64.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/base64.py This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data. It provides encoding and decoding f..." />
  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/base64.py This module provides functions for encoding binary data to printable ASCII characters and decoding such encodings back to binary data. It provides encoding and decoding f..." />
  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>base64 — Base16, Base32, Base64, Base85 Data Encodings &#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="binascii — Convert between binary and ASCII" href="binascii.html" />
  33. <link rel="prev" title="mimetypes — Map filenames to MIME types" href="mimetypes.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/base64.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">base64</span></code> — Base16, Base32, Base64, Base85 Data Encodings</a><ul>
  86. <li><a class="reference internal" href="#security-considerations">Security Considerations</a></li>
  87. </ul>
  88. </li>
  89. </ul>
  90. </div>
  91. <div>
  92. <h4>Previous topic</h4>
  93. <p class="topless"><a href="mimetypes.html"
  94. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mimetypes</span></code> — Map filenames to MIME types</a></p>
  95. </div>
  96. <div>
  97. <h4>Next topic</h4>
  98. <p class="topless"><a href="binascii.html"
  99. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">binascii</span></code> — Convert between binary and ASCII</a></p>
  100. </div>
  101. <div role="note" aria-label="source link">
  102. <h3>This Page</h3>
  103. <ul class="this-page-menu">
  104. <li><a href="../bugs.html">Report a Bug</a></li>
  105. <li>
  106. <a href="https://github.com/python/cpython/blob/main/Doc/library/base64.rst"
  107. rel="nofollow">Show Source
  108. </a>
  109. </li>
  110. </ul>
  111. </div>
  112. </nav>
  113. </div>
  114. </div>
  115. <div class="related" role="navigation" aria-label="related navigation">
  116. <h3>Navigation</h3>
  117. <ul>
  118. <li class="right" style="margin-right: 10px">
  119. <a href="../genindex.html" title="General Index"
  120. accesskey="I">index</a></li>
  121. <li class="right" >
  122. <a href="../py-modindex.html" title="Python Module Index"
  123. >modules</a> |</li>
  124. <li class="right" >
  125. <a href="binascii.html" title="binascii — Convert between binary and ASCII"
  126. accesskey="N">next</a> |</li>
  127. <li class="right" >
  128. <a href="mimetypes.html" title="mimetypes — Map filenames to MIME types"
  129. accesskey="P">previous</a> |</li>
  130. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  131. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  132. <li class="switchers">
  133. <div class="language_switcher_placeholder"></div>
  134. <div class="version_switcher_placeholder"></div>
  135. </li>
  136. <li>
  137. </li>
  138. <li id="cpython-language-and-version">
  139. <a href="../index.html">3.12.3 Documentation</a> &#187;
  140. </li>
  141. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  142. <li class="nav-item nav-item-2"><a href="netdata.html" accesskey="U">Internet Data Handling</a> &#187;</li>
  143. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code> — Base16, Base32, Base64, Base85 Data Encodings</a></li>
  144. <li class="right">
  145. <div class="inline-search" role="search">
  146. <form class="inline-search" action="../search.html" method="get">
  147. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  148. <input type="submit" value="Go" />
  149. </form>
  150. </div>
  151. |
  152. </li>
  153. <li class="right">
  154. <label class="theme-selector-label">
  155. Theme
  156. <select class="theme-selector" oninput="activateTheme(this.value)">
  157. <option value="auto" selected>Auto</option>
  158. <option value="light">Light</option>
  159. <option value="dark">Dark</option>
  160. </select>
  161. </label> |</li>
  162. </ul>
  163. </div>
  164. <div class="document">
  165. <div class="documentwrapper">
  166. <div class="bodywrapper">
  167. <div class="body" role="main">
  168. <section id="module-base64">
  169. <span id="base64-base16-base32-base64-base85-data-encodings"></span><h1><a class="reference internal" href="#module-base64" title="base64: RFC 4648: Base16, Base32, Base64 Data Encodings; Base85 and Ascii85"><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code></a> — Base16, Base32, Base64, Base85 Data Encodings<a class="headerlink" href="#module-base64" title="Link to this heading">¶</a></h1>
  170. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/base64.py">Lib/base64.py</a></p>
  171. <hr class="docutils" id="index-0" />
  172. <p>This module provides functions for encoding binary data to printable
  173. ASCII characters and decoding such encodings back to binary data.
  174. It provides encoding and decoding functions for the encodings specified in
  175. <span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a>, which defines the Base16, Base32, and Base64 algorithms,
  176. and for the de-facto standard Ascii85 and Base85 encodings.</p>
  177. <p>The <span class="target" id="index-2"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a> encodings are suitable for encoding binary data so that it can be
  178. safely sent by email, used as parts of URLs, or included as part of an HTTP
  179. POST request. The encoding algorithm is not the same as the
  180. <strong class="program">uuencode</strong> program.</p>
  181. <p>There are two interfaces provided by this module. The modern interface
  182. supports encoding <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a> to ASCII
  183. <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>, and decoding <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a> or
  184. strings containing ASCII to <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>. Both base-64 alphabets
  185. defined in <span class="target" id="index-3"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a> (normal, and URL- and filesystem-safe) are supported.</p>
  186. <p>The legacy interface does not support decoding from strings, but it does
  187. provide functions for encoding and decoding to and from <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file objects</span></a>. It only supports the Base64 standard alphabet, and it adds
  188. newlines every 76 characters as per <span class="target" id="index-4"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2045.html"><strong>RFC 2045</strong></a>. Note that if you are looking
  189. for <span class="target" id="index-5"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2045.html"><strong>RFC 2045</strong></a> support you probably want to be looking at the <a class="reference internal" href="email.html#module-email" title="email: Package supporting the parsing, manipulating, and generating email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code></a>
  190. package instead.</p>
  191. <div class="versionchanged">
  192. <p><span class="versionmodified changed">Changed in version 3.3: </span>ASCII-only Unicode strings are now accepted by the decoding functions of
  193. the modern interface.</p>
  194. </div>
  195. <div class="versionchanged">
  196. <p><span class="versionmodified changed">Changed in version 3.4: </span>Any <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a> are now accepted by all
  197. encoding and decoding functions in this module. Ascii85/Base85 support added.</p>
  198. </div>
  199. <p>The modern interface provides:</p>
  200. <dl class="py function">
  201. <dt class="sig sig-object py" id="base64.b64encode">
  202. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b64encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">altchars</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="#base64.b64encode" title="Link to this definition">¶</a></dt>
  203. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em> using Base64 and return the encoded
  204. <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>.</p>
  205. <p>Optional <em>altchars</em> must be a <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> of length 2 which
  206. specifies an alternative alphabet for the <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">/</span></code> characters.
  207. This allows an application to e.g. generate URL or filesystem safe Base64
  208. strings. The default is <code class="docutils literal notranslate"><span class="pre">None</span></code>, for which the standard Base64 alphabet is used.</p>
  209. <p>May assert or raise a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if the length of <em>altchars</em> is not 2. Raises a
  210. <a class="reference internal" href="exceptions.html#TypeError" title="TypeError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">TypeError</span></code></a> if <em>altchars</em> is not a <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a>.</p>
  211. </dd></dl>
  212. <dl class="py function">
  213. <dt class="sig sig-object py" id="base64.b64decode">
  214. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b64decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">altchars</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">validate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b64decode" title="Link to this definition">¶</a></dt>
  215. <dd><p>Decode the Base64 encoded <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string
  216. <em>s</em> and return the decoded <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>.</p>
  217. <p>Optional <em>altchars</em> must be a <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string
  218. of length 2 which specifies the alternative alphabet used instead of the
  219. <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">/</span></code> characters.</p>
  220. <p>A <a class="reference internal" href="binascii.html#binascii.Error" title="binascii.Error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">binascii.Error</span></code></a> exception is raised
  221. if <em>s</em> is incorrectly padded.</p>
  222. <p>If <em>validate</em> is <code class="docutils literal notranslate"><span class="pre">False</span></code> (the default), characters that are neither
  223. in the normal base-64 alphabet nor the alternative alphabet are
  224. discarded prior to the padding check. If <em>validate</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>,
  225. these non-alphabet characters in the input result in a
  226. <a class="reference internal" href="binascii.html#binascii.Error" title="binascii.Error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">binascii.Error</span></code></a>.</p>
  227. <p>For more information about the strict base64 check, see <a class="reference internal" href="binascii.html#binascii.a2b_base64" title="binascii.a2b_base64"><code class="xref py py-func docutils literal notranslate"><span class="pre">binascii.a2b_base64()</span></code></a></p>
  228. <p>May assert or raise a <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if the length of <em>altchars</em> is not 2.</p>
  229. </dd></dl>
  230. <dl class="py function">
  231. <dt class="sig sig-object py" id="base64.standard_b64encode">
  232. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">standard_b64encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.standard_b64encode" title="Link to this definition">¶</a></dt>
  233. <dd><p>Encode <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em> using the standard Base64 alphabet
  234. and return the encoded <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>.</p>
  235. </dd></dl>
  236. <dl class="py function">
  237. <dt class="sig sig-object py" id="base64.standard_b64decode">
  238. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">standard_b64decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.standard_b64decode" title="Link to this definition">¶</a></dt>
  239. <dd><p>Decode <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>s</em> using the standard
  240. Base64 alphabet and return the decoded <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>.</p>
  241. </dd></dl>
  242. <dl class="py function">
  243. <dt class="sig sig-object py" id="base64.urlsafe_b64encode">
  244. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">urlsafe_b64encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.urlsafe_b64encode" title="Link to this definition">¶</a></dt>
  245. <dd><p>Encode <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em> using the
  246. URL- and filesystem-safe alphabet, which
  247. substitutes <code class="docutils literal notranslate"><span class="pre">-</span></code> instead of <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">_</span></code> instead of <code class="docutils literal notranslate"><span class="pre">/</span></code> in the
  248. standard Base64 alphabet, and return the encoded <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>. The result
  249. can still contain <code class="docutils literal notranslate"><span class="pre">=</span></code>.</p>
  250. </dd></dl>
  251. <dl class="py function">
  252. <dt class="sig sig-object py" id="base64.urlsafe_b64decode">
  253. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">urlsafe_b64decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.urlsafe_b64decode" title="Link to this definition">¶</a></dt>
  254. <dd><p>Decode <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>s</em>
  255. using the URL- and filesystem-safe
  256. alphabet, which substitutes <code class="docutils literal notranslate"><span class="pre">-</span></code> instead of <code class="docutils literal notranslate"><span class="pre">+</span></code> and <code class="docutils literal notranslate"><span class="pre">_</span></code> instead of
  257. <code class="docutils literal notranslate"><span class="pre">/</span></code> in the standard Base64 alphabet, and return the decoded
  258. <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>.</p>
  259. </dd></dl>
  260. <dl class="py function">
  261. <dt class="sig sig-object py" id="base64.b32encode">
  262. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b32encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b32encode" title="Link to this definition">¶</a></dt>
  263. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em> using Base32 and return the
  264. encoded <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>.</p>
  265. </dd></dl>
  266. <dl class="py function">
  267. <dt class="sig sig-object py" id="base64.b32decode">
  268. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b32decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">casefold</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">map01</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="#base64.b32decode" title="Link to this definition">¶</a></dt>
  269. <dd><p>Decode the Base32 encoded <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>s</em> and
  270. return the decoded <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>.</p>
  271. <p>Optional <em>casefold</em> is a flag specifying
  272. whether a lowercase alphabet is acceptable as input. For security purposes,
  273. the default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
  274. <p><span class="target" id="index-6"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a> allows for optional mapping of the digit 0 (zero) to the letter O
  275. (oh), and for optional mapping of the digit 1 (one) to either the letter I (eye)
  276. or letter L (el). The optional argument <em>map01</em> when not <code class="docutils literal notranslate"><span class="pre">None</span></code>, specifies
  277. which letter the digit 1 should be mapped to (when <em>map01</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the
  278. digit 0 is always mapped to the letter O). For security purposes the default is
  279. <code class="docutils literal notranslate"><span class="pre">None</span></code>, so that 0 and 1 are not allowed in the input.</p>
  280. <p>A <a class="reference internal" href="binascii.html#binascii.Error" title="binascii.Error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">binascii.Error</span></code></a> is raised if <em>s</em> is
  281. incorrectly padded or if there are non-alphabet characters present in the
  282. input.</p>
  283. </dd></dl>
  284. <dl class="py function">
  285. <dt class="sig sig-object py" id="base64.b32hexencode">
  286. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b32hexencode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b32hexencode" title="Link to this definition">¶</a></dt>
  287. <dd><p>Similar to <a class="reference internal" href="#base64.b32encode" title="base64.b32encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32encode()</span></code></a> but uses the Extended Hex Alphabet, as defined in
  288. <span class="target" id="index-7"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a>.</p>
  289. <div class="versionadded">
  290. <p><span class="versionmodified added">New in version 3.10.</span></p>
  291. </div>
  292. </dd></dl>
  293. <dl class="py function">
  294. <dt class="sig sig-object py" id="base64.b32hexdecode">
  295. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b32hexdecode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">casefold</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b32hexdecode" title="Link to this definition">¶</a></dt>
  296. <dd><p>Similar to <a class="reference internal" href="#base64.b32decode" title="base64.b32decode"><code class="xref py py-func docutils literal notranslate"><span class="pre">b32decode()</span></code></a> but uses the Extended Hex Alphabet, as defined in
  297. <span class="target" id="index-8"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a>.</p>
  298. <p>This version does not allow the digit 0 (zero) to the letter O (oh) and digit
  299. 1 (one) to either the letter I (eye) or letter L (el) mappings, all these
  300. characters are included in the Extended Hex Alphabet and are not
  301. interchangeable.</p>
  302. <div class="versionadded">
  303. <p><span class="versionmodified added">New in version 3.10.</span></p>
  304. </div>
  305. </dd></dl>
  306. <dl class="py function">
  307. <dt class="sig sig-object py" id="base64.b16encode">
  308. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b16encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b16encode" title="Link to this definition">¶</a></dt>
  309. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em> using Base16 and return the
  310. encoded <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>.</p>
  311. </dd></dl>
  312. <dl class="py function">
  313. <dt class="sig sig-object py" id="base64.b16decode">
  314. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b16decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">casefold</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b16decode" title="Link to this definition">¶</a></dt>
  315. <dd><p>Decode the Base16 encoded <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>s</em> and
  316. return the decoded <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>.</p>
  317. <p>Optional <em>casefold</em> is a flag specifying whether a
  318. lowercase alphabet is acceptable as input. For security purposes, the default
  319. is <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p>
  320. <p>A <a class="reference internal" href="binascii.html#binascii.Error" title="binascii.Error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">binascii.Error</span></code></a> is raised if <em>s</em> is
  321. incorrectly padded or if there are non-alphabet characters present in the
  322. input.</p>
  323. </dd></dl>
  324. <dl class="py function">
  325. <dt class="sig sig-object py" id="base64.a85encode">
  326. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">a85encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</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">foldspaces</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">wrapcol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pad</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adobe</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.a85encode" title="Link to this definition">¶</a></dt>
  327. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>b</em> using Ascii85 and return the
  328. encoded <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>.</p>
  329. <p><em>foldspaces</em> is an optional flag that uses the special short sequence ‘y’
  330. instead of 4 consecutive spaces (ASCII 0x20) as supported by ‘btoa’. This
  331. feature is not supported by the “standard” Ascii85 encoding.</p>
  332. <p><em>wrapcol</em> controls whether the output should have newline (<code class="docutils literal notranslate"><span class="pre">b'\n'</span></code>)
  333. characters added to it. If this is non-zero, each output line will be
  334. at most this many characters long.</p>
  335. <p><em>pad</em> controls whether the input is padded to a multiple of 4
  336. before encoding. Note that the <code class="docutils literal notranslate"><span class="pre">btoa</span></code> implementation always pads.</p>
  337. <p><em>adobe</em> controls whether the encoded byte sequence is framed with <code class="docutils literal notranslate"><span class="pre">&lt;~</span></code>
  338. and <code class="docutils literal notranslate"><span class="pre">~&gt;</span></code>, which is used by the Adobe implementation.</p>
  339. <div class="versionadded">
  340. <p><span class="versionmodified added">New in version 3.4.</span></p>
  341. </div>
  342. </dd></dl>
  343. <dl class="py function">
  344. <dt class="sig sig-object py" id="base64.a85decode">
  345. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">a85decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</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">foldspaces</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">adobe</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignorechars</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">b'</span> <span class="pre">\t\n\r\x0b'</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.a85decode" title="Link to this definition">¶</a></dt>
  346. <dd><p>Decode the Ascii85 encoded <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>b</em> and
  347. return the decoded <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>.</p>
  348. <p><em>foldspaces</em> is a flag that specifies whether the ‘y’ short sequence
  349. should be accepted as shorthand for 4 consecutive spaces (ASCII 0x20).
  350. This feature is not supported by the “standard” Ascii85 encoding.</p>
  351. <p><em>adobe</em> controls whether the input sequence is in Adobe Ascii85 format
  352. (i.e. is framed with &lt;~ and ~&gt;).</p>
  353. <p><em>ignorechars</em> should be a <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string
  354. containing characters to ignore
  355. from the input. This should only contain whitespace characters, and by
  356. default contains all whitespace characters in ASCII.</p>
  357. <div class="versionadded">
  358. <p><span class="versionmodified added">New in version 3.4.</span></p>
  359. </div>
  360. </dd></dl>
  361. <dl class="py function">
  362. <dt class="sig sig-object py" id="base64.b85encode">
  363. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b85encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pad</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b85encode" title="Link to this definition">¶</a></dt>
  364. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>b</em> using base85 (as used in e.g.
  365. git-style binary diffs) and return the encoded <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>.</p>
  366. <p>If <em>pad</em> is true, the input is padded with <code class="docutils literal notranslate"><span class="pre">b'\0'</span></code> so its length is a
  367. multiple of 4 bytes before encoding.</p>
  368. <div class="versionadded">
  369. <p><span class="versionmodified added">New in version 3.4.</span></p>
  370. </div>
  371. </dd></dl>
  372. <dl class="py function">
  373. <dt class="sig sig-object py" id="base64.b85decode">
  374. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">b85decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">b</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.b85decode" title="Link to this definition">¶</a></dt>
  375. <dd><p>Decode the base85-encoded <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> or ASCII string <em>b</em> and
  376. return the decoded <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>. Padding is implicitly removed, if
  377. necessary.</p>
  378. <div class="versionadded">
  379. <p><span class="versionmodified added">New in version 3.4.</span></p>
  380. </div>
  381. </dd></dl>
  382. <p>The legacy interface:</p>
  383. <dl class="py function">
  384. <dt class="sig sig-object py" id="base64.decode">
  385. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">decode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.decode" title="Link to this definition">¶</a></dt>
  386. <dd><p>Decode the contents of the binary <em>input</em> file and write the resulting binary
  387. data to the <em>output</em> file. <em>input</em> and <em>output</em> must be <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file objects</span></a>. <em>input</em> will be read until <code class="docutils literal notranslate"><span class="pre">input.readline()</span></code> returns an
  388. empty bytes object.</p>
  389. </dd></dl>
  390. <dl class="py function">
  391. <dt class="sig sig-object py" id="base64.decodebytes">
  392. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">decodebytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.decodebytes" title="Link to this definition">¶</a></dt>
  393. <dd><p>Decode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em>, which must contain one or more
  394. lines of base64 encoded data, and return the decoded <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>.</p>
  395. <div class="versionadded">
  396. <p><span class="versionmodified added">New in version 3.1.</span></p>
  397. </div>
  398. </dd></dl>
  399. <dl class="py function">
  400. <dt class="sig sig-object py" id="base64.encode">
  401. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">encode</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">input</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">output</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.encode" title="Link to this definition">¶</a></dt>
  402. <dd><p>Encode the contents of the binary <em>input</em> file and write the resulting base64
  403. encoded data to the <em>output</em> file. <em>input</em> and <em>output</em> must be <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file
  404. objects</span></a>. <em>input</em> will be read until <code class="docutils literal notranslate"><span class="pre">input.read()</span></code> returns
  405. an empty bytes object. <a class="reference internal" href="#base64.encode" title="base64.encode"><code class="xref py py-func docutils literal notranslate"><span class="pre">encode()</span></code></a> inserts a newline character (<code class="docutils literal notranslate"><span class="pre">b'\n'</span></code>)
  406. after every 76 bytes of the output, as well as ensuring that the output
  407. always ends with a newline, as per <span class="target" id="index-9"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2045.html"><strong>RFC 2045</strong></a> (MIME).</p>
  408. </dd></dl>
  409. <dl class="py function">
  410. <dt class="sig sig-object py" id="base64.encodebytes">
  411. <span class="sig-prename descclassname"><span class="pre">base64.</span></span><span class="sig-name descname"><span class="pre">encodebytes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#base64.encodebytes" title="Link to this definition">¶</a></dt>
  412. <dd><p>Encode the <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> <em>s</em>, which can contain arbitrary binary
  413. data, and return <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> containing the base64-encoded data, with newlines
  414. (<code class="docutils literal notranslate"><span class="pre">b'\n'</span></code>) inserted after every 76 bytes of output, and ensuring that
  415. there is a trailing newline, as per <span class="target" id="index-10"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc2045.html"><strong>RFC 2045</strong></a> (MIME).</p>
  416. <div class="versionadded">
  417. <p><span class="versionmodified added">New in version 3.1.</span></p>
  418. </div>
  419. </dd></dl>
  420. <p>An example usage of the module:</p>
  421. <div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">base64</span>
  422. <span class="gp">&gt;&gt;&gt; </span><span class="n">encoded</span> <span class="o">=</span> <span class="n">base64</span><span class="o">.</span><span class="n">b64encode</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;data to be encoded&#39;</span><span class="p">)</span>
  423. <span class="gp">&gt;&gt;&gt; </span><span class="n">encoded</span>
  424. <span class="go">b&#39;ZGF0YSB0byBiZSBlbmNvZGVk&#39;</span>
  425. <span class="gp">&gt;&gt;&gt; </span><span class="n">data</span> <span class="o">=</span> <span class="n">base64</span><span class="o">.</span><span class="n">b64decode</span><span class="p">(</span><span class="n">encoded</span><span class="p">)</span>
  426. <span class="gp">&gt;&gt;&gt; </span><span class="n">data</span>
  427. <span class="go">b&#39;data to be encoded&#39;</span>
  428. </pre></div>
  429. </div>
  430. <section id="security-considerations">
  431. <span id="base64-security"></span><h2>Security Considerations<a class="headerlink" href="#security-considerations" title="Link to this heading">¶</a></h2>
  432. <p>A new security considerations section was added to <span class="target" id="index-11"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc4648.html"><strong>RFC 4648</strong></a> (section 12); it’s
  433. recommended to review the security section for any code deployed to production.</p>
  434. <div class="admonition seealso">
  435. <p class="admonition-title">See also</p>
  436. <dl class="simple">
  437. <dt>Module <a class="reference internal" href="binascii.html#module-binascii" title="binascii: Tools for converting between binary and various ASCII-encoded binary representations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">binascii</span></code></a></dt><dd><p>Support module containing ASCII-to-binary and binary-to-ASCII conversions.</p>
  438. </dd>
  439. <dt><span class="target" id="index-12"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc1521.html"><strong>RFC 1521</strong></a> - MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies</dt><dd><p>Section 5.2, “Base64 Content-Transfer-Encoding,” provides the definition of the
  440. base64 encoding.</p>
  441. </dd>
  442. </dl>
  443. </div>
  444. </section>
  445. </section>
  446. <div class="clearer"></div>
  447. </div>
  448. </div>
  449. </div>
  450. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  451. <div class="sphinxsidebarwrapper">
  452. <div>
  453. <h3><a href="../contents.html">Table of Contents</a></h3>
  454. <ul>
  455. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code> — Base16, Base32, Base64, Base85 Data Encodings</a><ul>
  456. <li><a class="reference internal" href="#security-considerations">Security Considerations</a></li>
  457. </ul>
  458. </li>
  459. </ul>
  460. </div>
  461. <div>
  462. <h4>Previous topic</h4>
  463. <p class="topless"><a href="mimetypes.html"
  464. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mimetypes</span></code> — Map filenames to MIME types</a></p>
  465. </div>
  466. <div>
  467. <h4>Next topic</h4>
  468. <p class="topless"><a href="binascii.html"
  469. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">binascii</span></code> — Convert between binary and ASCII</a></p>
  470. </div>
  471. <div role="note" aria-label="source link">
  472. <h3>This Page</h3>
  473. <ul class="this-page-menu">
  474. <li><a href="../bugs.html">Report a Bug</a></li>
  475. <li>
  476. <a href="https://github.com/python/cpython/blob/main/Doc/library/base64.rst"
  477. rel="nofollow">Show Source
  478. </a>
  479. </li>
  480. </ul>
  481. </div>
  482. </div>
  483. <div id="sidebarbutton" title="Collapse sidebar">
  484. <span>«</span>
  485. </div>
  486. </div>
  487. <div class="clearer"></div>
  488. </div>
  489. <div class="related" role="navigation" aria-label="related navigation">
  490. <h3>Navigation</h3>
  491. <ul>
  492. <li class="right" style="margin-right: 10px">
  493. <a href="../genindex.html" title="General Index"
  494. >index</a></li>
  495. <li class="right" >
  496. <a href="../py-modindex.html" title="Python Module Index"
  497. >modules</a> |</li>
  498. <li class="right" >
  499. <a href="binascii.html" title="binascii — Convert between binary and ASCII"
  500. >next</a> |</li>
  501. <li class="right" >
  502. <a href="mimetypes.html" title="mimetypes — Map filenames to MIME types"
  503. >previous</a> |</li>
  504. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  505. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  506. <li class="switchers">
  507. <div class="language_switcher_placeholder"></div>
  508. <div class="version_switcher_placeholder"></div>
  509. </li>
  510. <li>
  511. </li>
  512. <li id="cpython-language-and-version">
  513. <a href="../index.html">3.12.3 Documentation</a> &#187;
  514. </li>
  515. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  516. <li class="nav-item nav-item-2"><a href="netdata.html" >Internet Data Handling</a> &#187;</li>
  517. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">base64</span></code> — Base16, Base32, Base64, Base85 Data Encodings</a></li>
  518. <li class="right">
  519. <div class="inline-search" role="search">
  520. <form class="inline-search" action="../search.html" method="get">
  521. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  522. <input type="submit" value="Go" />
  523. </form>
  524. </div>
  525. |
  526. </li>
  527. <li class="right">
  528. <label class="theme-selector-label">
  529. Theme
  530. <select class="theme-selector" oninput="activateTheme(this.value)">
  531. <option value="auto" selected>Auto</option>
  532. <option value="light">Light</option>
  533. <option value="dark">Dark</option>
  534. </select>
  535. </label> |</li>
  536. </ul>
  537. </div>
  538. <div class="footer">
  539. &copy;
  540. <a href="../copyright.html">
  541. Copyright
  542. </a>
  543. 2001-2024, Python Software Foundation.
  544. <br />
  545. This page is licensed under the Python Software Foundation License Version 2.
  546. <br />
  547. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  548. <br />
  549. See <a href="/license.html">History and License</a> for more information.<br />
  550. <br />
  551. The Python Software Foundation is a non-profit corporation.
  552. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  553. <br />
  554. <br />
  555. Last updated on Apr 09, 2024 (13:47 UTC).
  556. <a href="/bugs.html">Found a bug</a>?
  557. <br />
  558. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  559. </div>
  560. </body>
  561. </html>
上海开阖软件有限公司 沪ICP备12045867号-1