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.

564 lines
52KB

  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="email.generator: Generating MIME documents" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/email.generator.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="Source code: Lib/email/generator.py One of the most common tasks is to generate the flat (serialized) version of the email message represented by a message object structure. You will need to do thi..." />
  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/email/generator.py One of the most common tasks is to generate the flat (serialized) version of the email message represented by a message object structure. You will need to do thi..." />
  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>email.generator: Generating MIME documents &#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="email.policy: Policy Objects" href="email.policy.html" />
  33. <link rel="prev" title="email.parser: Parsing email messages" href="email.parser.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/email.generator.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. <h4>Previous topic</h4>
  84. <p class="topless"><a href="email.parser.html"
  85. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.parser</span></code>: Parsing email messages</a></p>
  86. </div>
  87. <div>
  88. <h4>Next topic</h4>
  89. <p class="topless"><a href="email.policy.html"
  90. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code>: Policy Objects</a></p>
  91. </div>
  92. <div role="note" aria-label="source link">
  93. <h3>This Page</h3>
  94. <ul class="this-page-menu">
  95. <li><a href="../bugs.html">Report a Bug</a></li>
  96. <li>
  97. <a href="https://github.com/python/cpython/blob/main/Doc/library/email.generator.rst"
  98. rel="nofollow">Show Source
  99. </a>
  100. </li>
  101. </ul>
  102. </div>
  103. </nav>
  104. </div>
  105. </div>
  106. <div class="related" role="navigation" aria-label="related navigation">
  107. <h3>Navigation</h3>
  108. <ul>
  109. <li class="right" style="margin-right: 10px">
  110. <a href="../genindex.html" title="General Index"
  111. accesskey="I">index</a></li>
  112. <li class="right" >
  113. <a href="../py-modindex.html" title="Python Module Index"
  114. >modules</a> |</li>
  115. <li class="right" >
  116. <a href="email.policy.html" title="email.policy: Policy Objects"
  117. accesskey="N">next</a> |</li>
  118. <li class="right" >
  119. <a href="email.parser.html" title="email.parser: Parsing email messages"
  120. accesskey="P">previous</a> |</li>
  121. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  122. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  123. <li class="switchers">
  124. <div class="language_switcher_placeholder"></div>
  125. <div class="version_switcher_placeholder"></div>
  126. </li>
  127. <li>
  128. </li>
  129. <li id="cpython-language-and-version">
  130. <a href="../index.html">3.12.3 Documentation</a> &#187;
  131. </li>
  132. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  133. <li class="nav-item nav-item-2"><a href="netdata.html" >Internet Data Handling</a> &#187;</li>
  134. <li class="nav-item nav-item-3"><a href="email.html" accesskey="U"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> — An email and MIME handling package</a> &#187;</li>
  135. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.generator</span></code>: Generating MIME documents</a></li>
  136. <li class="right">
  137. <div class="inline-search" role="search">
  138. <form class="inline-search" action="../search.html" method="get">
  139. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  140. <input type="submit" value="Go" />
  141. </form>
  142. </div>
  143. |
  144. </li>
  145. <li class="right">
  146. <label class="theme-selector-label">
  147. Theme
  148. <select class="theme-selector" oninput="activateTheme(this.value)">
  149. <option value="auto" selected>Auto</option>
  150. <option value="light">Light</option>
  151. <option value="dark">Dark</option>
  152. </select>
  153. </label> |</li>
  154. </ul>
  155. </div>
  156. <div class="document">
  157. <div class="documentwrapper">
  158. <div class="bodywrapper">
  159. <div class="body" role="main">
  160. <section id="module-email.generator">
  161. <span id="email-generator-generating-mime-documents"></span><h1><a class="reference internal" href="#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.generator</span></code></a>: Generating MIME documents<a class="headerlink" href="#module-email.generator" title="Link to this heading">¶</a></h1>
  162. <p><strong>Source code:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.12/Lib/email/generator.py">Lib/email/generator.py</a></p>
  163. <hr class="docutils" />
  164. <p>One of the most common tasks is to generate the flat (serialized) version of
  165. the email message represented by a message object structure. You will need to
  166. do this if you want to send your message via <a class="reference internal" href="smtplib.html#smtplib.SMTP.sendmail" title="smtplib.SMTP.sendmail"><code class="xref py py-meth docutils literal notranslate"><span class="pre">smtplib.SMTP.sendmail()</span></code></a> or
  167. the <a class="reference internal" href="nntplib.html#module-nntplib" title="nntplib: NNTP protocol client (requires sockets). (deprecated)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">nntplib</span></code></a> module, or print the message on the console. Taking a
  168. message object structure and producing a serialized representation is the job
  169. of the generator classes.</p>
  170. <p>As with the <a class="reference internal" href="email.parser.html#module-email.parser" title="email.parser: Parse flat text email messages to produce a message object structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.parser</span></code></a> module, you aren’t limited to the functionality
  171. of the bundled generator; you could write one from scratch yourself. However
  172. the bundled generator knows how to generate most email in a standards-compliant
  173. way, should handle MIME and non-MIME email messages just fine, and is designed
  174. so that the bytes-oriented parsing and generation operations are inverses,
  175. assuming the same non-transforming <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> is used for both. That
  176. is, parsing the serialized byte stream via the
  177. <a class="reference internal" href="email.parser.html#email.parser.BytesParser" title="email.parser.BytesParser"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesParser</span></code></a> class and then regenerating the serialized
  178. byte stream using <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a> should produce output identical to
  179. the input <a class="footnote-reference brackets" href="#id3" id="id1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>. (On the other hand, using the generator on an
  180. <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> constructed by program may result in
  181. changes to the <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> object as defaults are
  182. filled in.)</p>
  183. <p>The <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> class can be used to flatten a message into a text (as
  184. opposed to binary) serialized representation, but since Unicode cannot
  185. represent binary data directly, the message is of necessity transformed into
  186. something that contains only ASCII characters, using the standard email RFC
  187. Content Transfer Encoding techniques for encoding email messages for transport
  188. over channels that are not “8 bit clean”.</p>
  189. <p>To accommodate reproducible processing of SMIME-signed messages
  190. <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> disables header folding for message parts of type
  191. <code class="docutils literal notranslate"><span class="pre">multipart/signed</span></code> and all subparts.</p>
  192. <dl class="py class">
  193. <dt class="sig sig-object py" id="email.generator.BytesGenerator">
  194. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">email.generator.</span></span><span class="sig-name descname"><span class="pre">BytesGenerator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">outfp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mangle_from_</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">maxheaderlen</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="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">policy</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="#email.generator.BytesGenerator" title="Link to this definition">¶</a></dt>
  195. <dd><p>Return a <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a> object that will write any message provided
  196. to the <a class="reference internal" href="#email.generator.BytesGenerator.flatten" title="email.generator.BytesGenerator.flatten"><code class="xref py py-meth docutils literal notranslate"><span class="pre">flatten()</span></code></a> method, or any surrogateescape encoded text provided
  197. to the <a class="reference internal" href="#email.generator.BytesGenerator.write" title="email.generator.BytesGenerator.write"><code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code></a> method, to the <a class="reference internal" href="../glossary.html#term-file-like-object"><span class="xref std std-term">file-like object</span></a> <em>outfp</em>.
  198. <em>outfp</em> must support a <code class="docutils literal notranslate"><span class="pre">write</span></code> method that accepts binary data.</p>
  199. <p>If optional <em>mangle_from_</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, put a <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> character in front of
  200. any line in the body that starts with the exact string <code class="docutils literal notranslate"><span class="pre">&quot;From</span> <span class="pre">&quot;</span></code>, that is
  201. <code class="docutils literal notranslate"><span class="pre">From</span></code> followed by a space at the beginning of a line. <em>mangle_from_</em>
  202. defaults to the value of the <a class="reference internal" href="email.policy.html#email.policy.Policy.mangle_from_" title="email.policy.Policy.mangle_from_"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mangle_from_</span></code></a>
  203. setting of the <em>policy</em> (which is <code class="docutils literal notranslate"><span class="pre">True</span></code> for the
  204. <a class="reference internal" href="email.policy.html#email.policy.compat32" title="email.policy.compat32"><code class="xref py py-data docutils literal notranslate"><span class="pre">compat32</span></code></a> policy and <code class="docutils literal notranslate"><span class="pre">False</span></code> for all others).
  205. <em>mangle_from_</em> is intended for use when messages are stored in Unix mbox
  206. format (see <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a> and <a class="reference external" href="https://www.jwz.org/doc/content-length.html">WHY THE CONTENT-LENGTH FORMAT IS BAD</a>).</p>
  207. <p>If <em>maxheaderlen</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, refold any header lines that are longer
  208. than <em>maxheaderlen</em>, or if <code class="docutils literal notranslate"><span class="pre">0</span></code>, do not rewrap any headers. If
  209. <em>manheaderlen</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the default), wrap headers and other message
  210. lines according to the <em>policy</em> settings.</p>
  211. <p>If <em>policy</em> is specified, use that policy to control message generation. If
  212. <em>policy</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the default), use the policy associated with the
  213. <a class="reference internal" href="email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a> or <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>
  214. object passed to <code class="docutils literal notranslate"><span class="pre">flatten</span></code> to control the message generation. See
  215. <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code></a> for details on what <em>policy</em> controls.</p>
  216. <div class="versionadded">
  217. <p><span class="versionmodified added">New in version 3.2.</span></p>
  218. </div>
  219. <div class="versionchanged">
  220. <p><span class="versionmodified changed">Changed in version 3.3: </span>Added the <em>policy</em> keyword.</p>
  221. </div>
  222. <div class="versionchanged">
  223. <p><span class="versionmodified changed">Changed in version 3.6: </span>The default behavior of the <em>mangle_from_</em>
  224. and <em>maxheaderlen</em> parameters is to follow the policy.</p>
  225. </div>
  226. <dl class="py method">
  227. <dt class="sig sig-object py" id="email.generator.BytesGenerator.flatten">
  228. <span class="sig-name descname"><span class="pre">flatten</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unixfrom</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">linesep</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="#email.generator.BytesGenerator.flatten" title="Link to this definition">¶</a></dt>
  229. <dd><p>Print the textual representation of the message object structure rooted
  230. at <em>msg</em> to the output file specified when the <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a>
  231. instance was created.</p>
  232. <p>If the <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> option <a class="reference internal" href="email.policy.html#email.policy.Policy.cte_type" title="email.policy.Policy.cte_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cte_type</span></code></a>
  233. is <code class="docutils literal notranslate"><span class="pre">8bit</span></code> (the default), copy any headers in the original parsed
  234. message that have not been modified to the output with any bytes with the
  235. high bit set reproduced as in the original, and preserve the non-ASCII
  236. <em class="mailheader">Content-Transfer-Encoding</em> of any body parts that have them.
  237. If <code class="docutils literal notranslate"><span class="pre">cte_type</span></code> is <code class="docutils literal notranslate"><span class="pre">7bit</span></code>, convert the bytes with the high bit set as
  238. needed using an ASCII-compatible <em class="mailheader">Content-Transfer-Encoding</em>.
  239. That is, transform parts with non-ASCII
  240. <em class="mailheader">Content-Transfer-Encoding</em>
  241. (<em class="mailheader">Content-Transfer-Encoding: 8bit</em>) to an ASCII compatible
  242. <em class="mailheader">Content-Transfer-Encoding</em>, and encode RFC-invalid non-ASCII
  243. bytes in headers using the MIME <code class="docutils literal notranslate"><span class="pre">unknown-8bit</span></code> character set, thus
  244. rendering them RFC-compliant.</p>
  245. <p>If <em>unixfrom</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, print the envelope header delimiter used by
  246. the Unix mailbox format (see <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a>) before the first of the
  247. <span class="target" id="index-0"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5322.html"><strong>RFC 5322</strong></a> headers of the root message object. If the root object has
  248. no envelope header, craft a standard one. The default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.
  249. Note that for subparts, no envelope header is ever printed.</p>
  250. <p>If <em>linesep</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, use it as the separator character between
  251. all the lines of the flattened message. If <em>linesep</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the
  252. default), use the value specified in the <em>policy</em>.</p>
  253. </dd></dl>
  254. <dl class="py method">
  255. <dt class="sig sig-object py" id="email.generator.BytesGenerator.clone">
  256. <span class="sig-name descname"><span class="pre">clone</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fp</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#email.generator.BytesGenerator.clone" title="Link to this definition">¶</a></dt>
  257. <dd><p>Return an independent clone of this <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a> instance with
  258. the exact same option settings, and <em>fp</em> as the new <em>outfp</em>.</p>
  259. </dd></dl>
  260. <dl class="py method">
  261. <dt class="sig sig-object py" id="email.generator.BytesGenerator.write">
  262. <span class="sig-name descname"><span class="pre">write</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="#email.generator.BytesGenerator.write" title="Link to this definition">¶</a></dt>
  263. <dd><p>Encode <em>s</em> using the <code class="docutils literal notranslate"><span class="pre">ASCII</span></code> codec and the <code class="docutils literal notranslate"><span class="pre">surrogateescape</span></code> error
  264. handler, and pass it to the <em>write</em> method of the <em>outfp</em> passed to the
  265. <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a>’s constructor.</p>
  266. </dd></dl>
  267. </dd></dl>
  268. <p>As a convenience, <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> provides the methods
  269. <a class="reference internal" href="email.message.html#email.message.EmailMessage.as_bytes" title="email.message.EmailMessage.as_bytes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">as_bytes()</span></code></a> and <code class="docutils literal notranslate"><span class="pre">bytes(aMessage)</span></code> (a.k.a.
  270. <a class="reference internal" href="email.message.html#email.message.EmailMessage.__bytes__" title="email.message.EmailMessage.__bytes__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__bytes__()</span></code></a>), which simplify the generation of
  271. a serialized binary representation of a message object. For more detail, see
  272. <a class="reference internal" href="email.message.html#module-email.message" title="email.message: The base class representing email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message</span></code></a>.</p>
  273. <p>Because strings cannot represent binary data, the <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> class must
  274. convert any binary data in any message it flattens to an ASCII compatible
  275. format, by converting them to an ASCII compatible
  276. <em class="mailheader">Content-Transfer_Encoding</em>. Using the terminology of the email
  277. RFCs, you can think of this as <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> serializing to an I/O stream
  278. that is not “8 bit clean”. In other words, most applications will want
  279. to be using <a class="reference internal" href="#email.generator.BytesGenerator" title="email.generator.BytesGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">BytesGenerator</span></code></a>, and not <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a>.</p>
  280. <dl class="py class">
  281. <dt class="sig sig-object py" id="email.generator.Generator">
  282. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">email.generator.</span></span><span class="sig-name descname"><span class="pre">Generator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">outfp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mangle_from_</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">maxheaderlen</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="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">policy</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="#email.generator.Generator" title="Link to this definition">¶</a></dt>
  283. <dd><p>Return a <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> object that will write any message provided
  284. to the <a class="reference internal" href="#email.generator.Generator.flatten" title="email.generator.Generator.flatten"><code class="xref py py-meth docutils literal notranslate"><span class="pre">flatten()</span></code></a> method, or any text provided to the <a class="reference internal" href="#email.generator.Generator.write" title="email.generator.Generator.write"><code class="xref py py-meth docutils literal notranslate"><span class="pre">write()</span></code></a>
  285. method, to the <a class="reference internal" href="../glossary.html#term-file-like-object"><span class="xref std std-term">file-like object</span></a> <em>outfp</em>. <em>outfp</em> must support a
  286. <code class="docutils literal notranslate"><span class="pre">write</span></code> method that accepts string data.</p>
  287. <p>If optional <em>mangle_from_</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, put a <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> character in front of
  288. any line in the body that starts with the exact string <code class="docutils literal notranslate"><span class="pre">&quot;From</span> <span class="pre">&quot;</span></code>, that is
  289. <code class="docutils literal notranslate"><span class="pre">From</span></code> followed by a space at the beginning of a line. <em>mangle_from_</em>
  290. defaults to the value of the <a class="reference internal" href="email.policy.html#email.policy.Policy.mangle_from_" title="email.policy.Policy.mangle_from_"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mangle_from_</span></code></a>
  291. setting of the <em>policy</em> (which is <code class="docutils literal notranslate"><span class="pre">True</span></code> for the
  292. <a class="reference internal" href="email.policy.html#email.policy.compat32" title="email.policy.compat32"><code class="xref py py-data docutils literal notranslate"><span class="pre">compat32</span></code></a> policy and <code class="docutils literal notranslate"><span class="pre">False</span></code> for all others).
  293. <em>mangle_from_</em> is intended for use when messages are stored in Unix mbox
  294. format (see <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a> and <a class="reference external" href="https://www.jwz.org/doc/content-length.html">WHY THE CONTENT-LENGTH FORMAT IS BAD</a>).</p>
  295. <p>If <em>maxheaderlen</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, refold any header lines that are longer
  296. than <em>maxheaderlen</em>, or if <code class="docutils literal notranslate"><span class="pre">0</span></code>, do not rewrap any headers. If
  297. <em>manheaderlen</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the default), wrap headers and other message
  298. lines according to the <em>policy</em> settings.</p>
  299. <p>If <em>policy</em> is specified, use that policy to control message generation. If
  300. <em>policy</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the default), use the policy associated with the
  301. <a class="reference internal" href="email.compat32-message.html#email.message.Message" title="email.message.Message"><code class="xref py py-class docutils literal notranslate"><span class="pre">Message</span></code></a> or <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a>
  302. object passed to <code class="docutils literal notranslate"><span class="pre">flatten</span></code> to control the message generation. See
  303. <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code></a> for details on what <em>policy</em> controls.</p>
  304. <div class="versionchanged">
  305. <p><span class="versionmodified changed">Changed in version 3.3: </span>Added the <em>policy</em> keyword.</p>
  306. </div>
  307. <div class="versionchanged">
  308. <p><span class="versionmodified changed">Changed in version 3.6: </span>The default behavior of the <em>mangle_from_</em>
  309. and <em>maxheaderlen</em> parameters is to follow the policy.</p>
  310. </div>
  311. <dl class="py method">
  312. <dt class="sig sig-object py" id="email.generator.Generator.flatten">
  313. <span class="sig-name descname"><span class="pre">flatten</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">msg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">unixfrom</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">linesep</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="#email.generator.Generator.flatten" title="Link to this definition">¶</a></dt>
  314. <dd><p>Print the textual representation of the message object structure rooted
  315. at <em>msg</em> to the output file specified when the <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a>
  316. instance was created.</p>
  317. <p>If the <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">policy</span></code></a> option <a class="reference internal" href="email.policy.html#email.policy.Policy.cte_type" title="email.policy.Policy.cte_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cte_type</span></code></a>
  318. is <code class="docutils literal notranslate"><span class="pre">8bit</span></code>, generate the message as if the option were set to <code class="docutils literal notranslate"><span class="pre">7bit</span></code>.
  319. (This is required because strings cannot represent non-ASCII bytes.)
  320. Convert any bytes with the high bit set as needed using an
  321. ASCII-compatible <em class="mailheader">Content-Transfer-Encoding</em>. That is,
  322. transform parts with non-ASCII <em class="mailheader">Content-Transfer-Encoding</em>
  323. (<em class="mailheader">Content-Transfer-Encoding: 8bit</em>) to an ASCII compatible
  324. <em class="mailheader">Content-Transfer-Encoding</em>, and encode RFC-invalid non-ASCII
  325. bytes in headers using the MIME <code class="docutils literal notranslate"><span class="pre">unknown-8bit</span></code> character set, thus
  326. rendering them RFC-compliant.</p>
  327. <p>If <em>unixfrom</em> is <code class="docutils literal notranslate"><span class="pre">True</span></code>, print the envelope header delimiter used by
  328. the Unix mailbox format (see <a class="reference internal" href="mailbox.html#module-mailbox" title="mailbox: Manipulate mailboxes in various formats"><code class="xref py py-mod docutils literal notranslate"><span class="pre">mailbox</span></code></a>) before the first of the
  329. <span class="target" id="index-1"></span><a class="rfc reference external" href="https://datatracker.ietf.org/doc/html/rfc5322.html"><strong>RFC 5322</strong></a> headers of the root message object. If the root object has
  330. no envelope header, craft a standard one. The default is <code class="docutils literal notranslate"><span class="pre">False</span></code>.
  331. Note that for subparts, no envelope header is ever printed.</p>
  332. <p>If <em>linesep</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, use it as the separator character between
  333. all the lines of the flattened message. If <em>linesep</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code> (the
  334. default), use the value specified in the <em>policy</em>.</p>
  335. <div class="versionchanged">
  336. <p><span class="versionmodified changed">Changed in version 3.2: </span>Added support for re-encoding <code class="docutils literal notranslate"><span class="pre">8bit</span></code> message bodies, and the
  337. <em>linesep</em> argument.</p>
  338. </div>
  339. </dd></dl>
  340. <dl class="py method">
  341. <dt class="sig sig-object py" id="email.generator.Generator.clone">
  342. <span class="sig-name descname"><span class="pre">clone</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fp</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#email.generator.Generator.clone" title="Link to this definition">¶</a></dt>
  343. <dd><p>Return an independent clone of this <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> instance with the
  344. exact same options, and <em>fp</em> as the new <em>outfp</em>.</p>
  345. </dd></dl>
  346. <dl class="py method">
  347. <dt class="sig sig-object py" id="email.generator.Generator.write">
  348. <span class="sig-name descname"><span class="pre">write</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="#email.generator.Generator.write" title="Link to this definition">¶</a></dt>
  349. <dd><p>Write <em>s</em> to the <em>write</em> method of the <em>outfp</em> passed to the
  350. <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a>’s constructor. This provides just enough file-like
  351. API for <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> instances to be used in the <a class="reference internal" href="functions.html#print" title="print"><code class="xref py py-func docutils literal notranslate"><span class="pre">print()</span></code></a>
  352. function.</p>
  353. </dd></dl>
  354. </dd></dl>
  355. <p>As a convenience, <a class="reference internal" href="email.message.html#email.message.EmailMessage" title="email.message.EmailMessage"><code class="xref py py-class docutils literal notranslate"><span class="pre">EmailMessage</span></code></a> provides the methods
  356. <a class="reference internal" href="email.message.html#email.message.EmailMessage.as_string" title="email.message.EmailMessage.as_string"><code class="xref py py-meth docutils literal notranslate"><span class="pre">as_string()</span></code></a> and <code class="docutils literal notranslate"><span class="pre">str(aMessage)</span></code> (a.k.a.
  357. <a class="reference internal" href="email.message.html#email.message.EmailMessage.__str__" title="email.message.EmailMessage.__str__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__str__()</span></code></a>), which simplify the generation of
  358. a formatted string representation of a message object. For more detail, see
  359. <a class="reference internal" href="email.message.html#module-email.message" title="email.message: The base class representing email messages."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.message</span></code></a>.</p>
  360. <p>The <a class="reference internal" href="#module-email.generator" title="email.generator: Generate flat text email messages from a message structure."><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.generator</span></code></a> module also provides a derived class,
  361. <a class="reference internal" href="#email.generator.DecodedGenerator" title="email.generator.DecodedGenerator"><code class="xref py py-class docutils literal notranslate"><span class="pre">DecodedGenerator</span></code></a>, which is like the <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> base class,
  362. except that non-<em class="mimetype">text</em> parts are not serialized, but are instead
  363. represented in the output stream by a string derived from a template filled
  364. in with information about the part.</p>
  365. <dl class="py class">
  366. <dt class="sig sig-object py" id="email.generator.DecodedGenerator">
  367. <em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">email.generator.</span></span><span class="sig-name descname"><span class="pre">DecodedGenerator</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">outfp</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mangle_from_</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">maxheaderlen</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">fmt</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="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">policy</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="#email.generator.DecodedGenerator" title="Link to this definition">¶</a></dt>
  368. <dd><p>Act like <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a>, except that for any subpart of the message
  369. passed to <a class="reference internal" href="#email.generator.Generator.flatten" title="email.generator.Generator.flatten"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Generator.flatten()</span></code></a>, if the subpart is of main type
  370. <em class="mimetype">text</em>, print the decoded payload of the subpart, and if the main
  371. type is not <em class="mimetype">text</em>, instead of printing it fill in the string
  372. <em>fmt</em> using information from the part and print the resulting
  373. filled-in string.</p>
  374. <p>To fill in <em>fmt</em>, execute <code class="docutils literal notranslate"><span class="pre">fmt</span> <span class="pre">%</span> <span class="pre">part_info</span></code>, where <code class="docutils literal notranslate"><span class="pre">part_info</span></code>
  375. is a dictionary composed of the following keys and values:</p>
  376. <ul class="simple">
  377. <li><p><code class="docutils literal notranslate"><span class="pre">type</span></code> – Full MIME type of the non-<em class="mimetype">text</em> part</p></li>
  378. <li><p><code class="docutils literal notranslate"><span class="pre">maintype</span></code> – Main MIME type of the non-<em class="mimetype">text</em> part</p></li>
  379. <li><p><code class="docutils literal notranslate"><span class="pre">subtype</span></code> – Sub-MIME type of the non-<em class="mimetype">text</em> part</p></li>
  380. <li><p><code class="docutils literal notranslate"><span class="pre">filename</span></code> – Filename of the non-<em class="mimetype">text</em> part</p></li>
  381. <li><p><code class="docutils literal notranslate"><span class="pre">description</span></code> – Description associated with the non-<em class="mimetype">text</em> part</p></li>
  382. <li><p><code class="docutils literal notranslate"><span class="pre">encoding</span></code> – Content transfer encoding of the non-<em class="mimetype">text</em> part</p></li>
  383. </ul>
  384. <p>If <em>fmt</em> is <code class="docutils literal notranslate"><span class="pre">None</span></code>, use the following default <em>fmt</em>:</p>
  385. <blockquote>
  386. <div><p>“[Non-text (%(type)s) part of message omitted, filename %(filename)s]”</p>
  387. </div></blockquote>
  388. <p>Optional <em>_mangle_from_</em> and <em>maxheaderlen</em> are as with the
  389. <a class="reference internal" href="#email.generator.Generator" title="email.generator.Generator"><code class="xref py py-class docutils literal notranslate"><span class="pre">Generator</span></code></a> base class.</p>
  390. </dd></dl>
  391. <p class="rubric">Footnotes</p>
  392. <aside class="footnote-list brackets">
  393. <aside class="footnote brackets" id="id3" role="doc-footnote">
  394. <span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id1">1</a><span class="fn-bracket">]</span></span>
  395. <p>This statement assumes that you use the appropriate setting for
  396. <code class="docutils literal notranslate"><span class="pre">unixfrom</span></code>, and that there are no <a class="reference internal" href="email.policy.html#module-email.policy" title="email.policy: Controlling the parsing and generating of messages"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code></a> settings calling for
  397. automatic adjustments (for example,
  398. <a class="reference internal" href="email.policy.html#email.policy.EmailPolicy.refold_source" title="email.policy.EmailPolicy.refold_source"><code class="xref py py-attr docutils literal notranslate"><span class="pre">refold_source</span></code></a> must be <code class="docutils literal notranslate"><span class="pre">none</span></code>, which is
  399. <em>not</em> the default). It is also not 100% true, since if the message
  400. does not conform to the RFC standards occasionally information about the
  401. exact original text is lost during parsing error recovery. It is a goal
  402. to fix these latter edge cases when possible.</p>
  403. </aside>
  404. </aside>
  405. </section>
  406. <div class="clearer"></div>
  407. </div>
  408. </div>
  409. </div>
  410. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  411. <div class="sphinxsidebarwrapper">
  412. <div>
  413. <h4>Previous topic</h4>
  414. <p class="topless"><a href="email.parser.html"
  415. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.parser</span></code>: Parsing email messages</a></p>
  416. </div>
  417. <div>
  418. <h4>Next topic</h4>
  419. <p class="topless"><a href="email.policy.html"
  420. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.policy</span></code>: Policy Objects</a></p>
  421. </div>
  422. <div role="note" aria-label="source link">
  423. <h3>This Page</h3>
  424. <ul class="this-page-menu">
  425. <li><a href="../bugs.html">Report a Bug</a></li>
  426. <li>
  427. <a href="https://github.com/python/cpython/blob/main/Doc/library/email.generator.rst"
  428. rel="nofollow">Show Source
  429. </a>
  430. </li>
  431. </ul>
  432. </div>
  433. </div>
  434. <div id="sidebarbutton" title="Collapse sidebar">
  435. <span>«</span>
  436. </div>
  437. </div>
  438. <div class="clearer"></div>
  439. </div>
  440. <div class="related" role="navigation" aria-label="related navigation">
  441. <h3>Navigation</h3>
  442. <ul>
  443. <li class="right" style="margin-right: 10px">
  444. <a href="../genindex.html" title="General Index"
  445. >index</a></li>
  446. <li class="right" >
  447. <a href="../py-modindex.html" title="Python Module Index"
  448. >modules</a> |</li>
  449. <li class="right" >
  450. <a href="email.policy.html" title="email.policy: Policy Objects"
  451. >next</a> |</li>
  452. <li class="right" >
  453. <a href="email.parser.html" title="email.parser: Parsing email messages"
  454. >previous</a> |</li>
  455. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  456. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  457. <li class="switchers">
  458. <div class="language_switcher_placeholder"></div>
  459. <div class="version_switcher_placeholder"></div>
  460. </li>
  461. <li>
  462. </li>
  463. <li id="cpython-language-and-version">
  464. <a href="../index.html">3.12.3 Documentation</a> &#187;
  465. </li>
  466. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  467. <li class="nav-item nav-item-2"><a href="netdata.html" >Internet Data Handling</a> &#187;</li>
  468. <li class="nav-item nav-item-3"><a href="email.html" ><code class="xref py py-mod docutils literal notranslate"><span class="pre">email</span></code> — An email and MIME handling package</a> &#187;</li>
  469. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">email.generator</span></code>: Generating MIME documents</a></li>
  470. <li class="right">
  471. <div class="inline-search" role="search">
  472. <form class="inline-search" action="../search.html" method="get">
  473. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  474. <input type="submit" value="Go" />
  475. </form>
  476. </div>
  477. |
  478. </li>
  479. <li class="right">
  480. <label class="theme-selector-label">
  481. Theme
  482. <select class="theme-selector" oninput="activateTheme(this.value)">
  483. <option value="auto" selected>Auto</option>
  484. <option value="light">Light</option>
  485. <option value="dark">Dark</option>
  486. </select>
  487. </label> |</li>
  488. </ul>
  489. </div>
  490. <div class="footer">
  491. &copy;
  492. <a href="../copyright.html">
  493. Copyright
  494. </a>
  495. 2001-2024, Python Software Foundation.
  496. <br />
  497. This page is licensed under the Python Software Foundation License Version 2.
  498. <br />
  499. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  500. <br />
  501. See <a href="/license.html">History and License</a> for more information.<br />
  502. <br />
  503. The Python Software Foundation is a non-profit corporation.
  504. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  505. <br />
  506. <br />
  507. Last updated on Apr 09, 2024 (13:47 UTC).
  508. <a href="/bugs.html">Found a bug</a>?
  509. <br />
  510. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  511. </div>
  512. </body>
  513. </html>
上海开阖软件有限公司 沪ICP备12045867号-1