gooderp18绿色标准版
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

424 lines
21KB

  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="Introduction" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/intro.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="The “Python library” contains several different kinds of components. It contains data types that would normally be considered part of the “core” of a language, such as numbers and lists. For these ..." />
  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="The “Python library” contains several different kinds of components. It contains data types that would normally be considered part of the “core” of a language, such as numbers and lists. For these ..." />
  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>Introduction &#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="Built-in Functions" href="functions.html" />
  33. <link rel="prev" title="The Python Standard Library" href="index.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/intro.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="#">Introduction</a><ul>
  86. <li><a class="reference internal" href="#notes-on-availability">Notes on availability</a><ul>
  87. <li><a class="reference internal" href="#webassembly-platforms">WebAssembly platforms</a></li>
  88. </ul>
  89. </li>
  90. </ul>
  91. </li>
  92. </ul>
  93. </div>
  94. <div>
  95. <h4>Previous topic</h4>
  96. <p class="topless"><a href="index.html"
  97. title="previous chapter">The Python Standard Library</a></p>
  98. </div>
  99. <div>
  100. <h4>Next topic</h4>
  101. <p class="topless"><a href="functions.html"
  102. title="next chapter">Built-in Functions</a></p>
  103. </div>
  104. <div role="note" aria-label="source link">
  105. <h3>This Page</h3>
  106. <ul class="this-page-menu">
  107. <li><a href="../bugs.html">Report a Bug</a></li>
  108. <li>
  109. <a href="https://github.com/python/cpython/blob/main/Doc/library/intro.rst"
  110. rel="nofollow">Show Source
  111. </a>
  112. </li>
  113. </ul>
  114. </div>
  115. </nav>
  116. </div>
  117. </div>
  118. <div class="related" role="navigation" aria-label="related navigation">
  119. <h3>Navigation</h3>
  120. <ul>
  121. <li class="right" style="margin-right: 10px">
  122. <a href="../genindex.html" title="General Index"
  123. accesskey="I">index</a></li>
  124. <li class="right" >
  125. <a href="../py-modindex.html" title="Python Module Index"
  126. >modules</a> |</li>
  127. <li class="right" >
  128. <a href="functions.html" title="Built-in Functions"
  129. accesskey="N">next</a> |</li>
  130. <li class="right" >
  131. <a href="index.html" title="The Python Standard Library"
  132. accesskey="P">previous</a> |</li>
  133. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  134. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  135. <li class="switchers">
  136. <div class="language_switcher_placeholder"></div>
  137. <div class="version_switcher_placeholder"></div>
  138. </li>
  139. <li>
  140. </li>
  141. <li id="cpython-language-and-version">
  142. <a href="../index.html">3.12.3 Documentation</a> &#187;
  143. </li>
  144. <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Standard Library</a> &#187;</li>
  145. <li class="nav-item nav-item-this"><a href="">Introduction</a></li>
  146. <li class="right">
  147. <div class="inline-search" role="search">
  148. <form class="inline-search" action="../search.html" method="get">
  149. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  150. <input type="submit" value="Go" />
  151. </form>
  152. </div>
  153. |
  154. </li>
  155. <li class="right">
  156. <label class="theme-selector-label">
  157. Theme
  158. <select class="theme-selector" oninput="activateTheme(this.value)">
  159. <option value="auto" selected>Auto</option>
  160. <option value="light">Light</option>
  161. <option value="dark">Dark</option>
  162. </select>
  163. </label> |</li>
  164. </ul>
  165. </div>
  166. <div class="document">
  167. <div class="documentwrapper">
  168. <div class="bodywrapper">
  169. <div class="body" role="main">
  170. <section id="introduction">
  171. <span id="library-intro"></span><h1>Introduction<a class="headerlink" href="#introduction" title="Link to this heading">¶</a></h1>
  172. <p>The “Python library” contains several different kinds of components.</p>
  173. <p>It contains data types that would normally be considered part of the “core” of a
  174. language, such as numbers and lists. For these types, the Python language core
  175. defines the form of literals and places some constraints on their semantics, but
  176. does not fully define the semantics. (On the other hand, the language core does
  177. define syntactic properties like the spelling and priorities of operators.)</p>
  178. <p>The library also contains built-in functions and exceptions — objects that can
  179. be used by all Python code without the need of an <a class="reference internal" href="../reference/simple_stmts.html#import"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">import</span></code></a> statement.
  180. Some of these are defined by the core language, but many are not essential for
  181. the core semantics and are only described here.</p>
  182. <p>The bulk of the library, however, consists of a collection of modules. There are
  183. many ways to dissect this collection. Some modules are written in C and built
  184. in to the Python interpreter; others are written in Python and imported in
  185. source form. Some modules provide interfaces that are highly specific to
  186. Python, like printing a stack trace; some provide interfaces that are specific
  187. to particular operating systems, such as access to specific hardware; others
  188. provide interfaces that are specific to a particular application domain, like
  189. the World Wide Web. Some modules are available in all versions and ports of
  190. Python; others are only available when the underlying system supports or
  191. requires them; yet others are available only when a particular configuration
  192. option was chosen at the time when Python was compiled and installed.</p>
  193. <p>This manual is organized “from the inside out:” it first describes the built-in
  194. functions, data types and exceptions, and finally the modules, grouped in
  195. chapters of related modules.</p>
  196. <p>This means that if you start reading this manual from the start, and skip to the
  197. next chapter when you get bored, you will get a reasonable overview of the
  198. available modules and application areas that are supported by the Python
  199. library. Of course, you don’t <em>have</em> to read it like a novel — you can also
  200. browse the table of contents (in front of the manual), or look for a specific
  201. function, module or term in the index (in the back). And finally, if you enjoy
  202. learning about random subjects, you choose a random page number (see module
  203. <a class="reference internal" href="random.html#module-random" title="random: Generate pseudo-random numbers with various common distributions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">random</span></code></a>) and read a section or two. Regardless of the order in which you
  204. read the sections of this manual, it helps to start with chapter
  205. <a class="reference internal" href="functions.html#built-in-funcs"><span class="std std-ref">Built-in Functions</span></a>, as the remainder of the manual assumes familiarity with
  206. this material.</p>
  207. <p>Let the show begin!</p>
  208. <section id="notes-on-availability">
  209. <span id="availability"></span><h2>Notes on availability<a class="headerlink" href="#notes-on-availability" title="Link to this heading">¶</a></h2>
  210. <ul class="simple">
  211. <li><p>An “Availability: Unix” note means that this function is commonly found on
  212. Unix systems. It does not make any claims about its existence on a specific
  213. operating system.</p></li>
  214. <li><p>If not separately noted, all functions that claim “Availability: Unix” are
  215. supported on macOS, which builds on a Unix core.</p></li>
  216. <li><p>If an availability note contains both a minimum Kernel version and a minimum
  217. libc version, then both conditions must hold. For example a feature with note
  218. <em>Availability: Linux &gt;= 3.17 with glibc &gt;= 2.27</em> requires both Linux 3.17 or
  219. newer and glibc 2.27 or newer.</p></li>
  220. </ul>
  221. <section id="webassembly-platforms">
  222. <span id="wasm-availability"></span><h3>WebAssembly platforms<a class="headerlink" href="#webassembly-platforms" title="Link to this heading">¶</a></h3>
  223. <p>The <a class="reference external" href="https://webassembly.org/">WebAssembly</a> platforms <code class="docutils literal notranslate"><span class="pre">wasm32-emscripten</span></code> (<a class="reference external" href="https://emscripten.org/">Emscripten</a>) and
  224. <code class="docutils literal notranslate"><span class="pre">wasm32-wasi</span></code> (<a class="reference external" href="https://wasi.dev/">WASI</a>) provide a subset of POSIX APIs. WebAssembly runtimes
  225. and browsers are sandboxed and have limited access to the host and external
  226. resources. Any Python standard library module that uses processes, threading,
  227. networking, signals, or other forms of inter-process communication (IPC), is
  228. either not available or may not work as on other Unix-like systems. File I/O,
  229. file system, and Unix permission-related functions are restricted, too.
  230. Emscripten does not permit blocking I/O. Other blocking operations like
  231. <a class="reference internal" href="time.html#time.sleep" title="time.sleep"><code class="xref py py-func docutils literal notranslate"><span class="pre">sleep()</span></code></a> block the browser event loop.</p>
  232. <p>The properties and behavior of Python on WebAssembly platforms depend on the
  233. <a class="reference external" href="https://emscripten.org/">Emscripten</a>-SDK or <a class="reference external" href="https://wasi.dev/">WASI</a>-SDK version, WASM runtimes (browser, NodeJS,
  234. <a class="reference external" href="https://wasmtime.dev/">wasmtime</a>), and Python build time flags. WebAssembly, Emscripten, and WASI
  235. are evolving standards; some features like networking may be
  236. supported in the future.</p>
  237. <p>For Python in the browser, users should consider <a class="reference external" href="https://pyodide.org/">Pyodide</a> or <a class="reference external" href="https://pyscript.net/">PyScript</a>.
  238. PyScript is built on top of Pyodide, which itself is built on top of
  239. CPython and Emscripten. Pyodide provides access to browsers’ JavaScript and
  240. DOM APIs as well as limited networking capabilities with JavaScript’s
  241. <code class="docutils literal notranslate"><span class="pre">XMLHttpRequest</span></code> and <code class="docutils literal notranslate"><span class="pre">Fetch</span></code> APIs.</p>
  242. <ul class="simple">
  243. <li><p>Process-related APIs are not available or always fail with an error. That
  244. includes APIs that spawn new processes (<a class="reference internal" href="os.html#os.fork" title="os.fork"><code class="xref py py-func docutils literal notranslate"><span class="pre">fork()</span></code></a>,
  245. <a class="reference internal" href="os.html#os.execve" title="os.execve"><code class="xref py py-func docutils literal notranslate"><span class="pre">execve()</span></code></a>), wait for processes (<a class="reference internal" href="os.html#os.waitpid" title="os.waitpid"><code class="xref py py-func docutils literal notranslate"><span class="pre">waitpid()</span></code></a>), send signals
  246. (<a class="reference internal" href="os.html#os.kill" title="os.kill"><code class="xref py py-func docutils literal notranslate"><span class="pre">kill()</span></code></a>), or otherwise interact with processes. The
  247. <a class="reference internal" href="subprocess.html#module-subprocess" title="subprocess: Subprocess management."><code class="xref py py-mod docutils literal notranslate"><span class="pre">subprocess</span></code></a> is importable but does not work.</p></li>
  248. <li><p>The <a class="reference internal" href="socket.html#module-socket" title="socket: Low-level networking interface."><code class="xref py py-mod docutils literal notranslate"><span class="pre">socket</span></code></a> module is available, but is limited and behaves
  249. differently from other platforms. On Emscripten, sockets are always
  250. non-blocking and require additional JavaScript code and helpers on the
  251. server to proxy TCP through WebSockets; see <a class="reference external" href="https://emscripten.org/docs/porting/networking.html">Emscripten Networking</a>
  252. for more information. WASI snapshot preview 1 only permits sockets from an
  253. existing file descriptor.</p></li>
  254. <li><p>Some functions are stubs that either don’t do anything and always return
  255. hardcoded values.</p></li>
  256. <li><p>Functions related to file descriptors, file permissions, file ownership, and
  257. links are limited and don’t support some operations. For example, WASI does
  258. not permit symlinks with absolute file names.</p></li>
  259. </ul>
  260. </section>
  261. </section>
  262. </section>
  263. <div class="clearer"></div>
  264. </div>
  265. </div>
  266. </div>
  267. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  268. <div class="sphinxsidebarwrapper">
  269. <div>
  270. <h3><a href="../contents.html">Table of Contents</a></h3>
  271. <ul>
  272. <li><a class="reference internal" href="#">Introduction</a><ul>
  273. <li><a class="reference internal" href="#notes-on-availability">Notes on availability</a><ul>
  274. <li><a class="reference internal" href="#webassembly-platforms">WebAssembly platforms</a></li>
  275. </ul>
  276. </li>
  277. </ul>
  278. </li>
  279. </ul>
  280. </div>
  281. <div>
  282. <h4>Previous topic</h4>
  283. <p class="topless"><a href="index.html"
  284. title="previous chapter">The Python Standard Library</a></p>
  285. </div>
  286. <div>
  287. <h4>Next topic</h4>
  288. <p class="topless"><a href="functions.html"
  289. title="next chapter">Built-in Functions</a></p>
  290. </div>
  291. <div role="note" aria-label="source link">
  292. <h3>This Page</h3>
  293. <ul class="this-page-menu">
  294. <li><a href="../bugs.html">Report a Bug</a></li>
  295. <li>
  296. <a href="https://github.com/python/cpython/blob/main/Doc/library/intro.rst"
  297. rel="nofollow">Show Source
  298. </a>
  299. </li>
  300. </ul>
  301. </div>
  302. </div>
  303. <div id="sidebarbutton" title="Collapse sidebar">
  304. <span>«</span>
  305. </div>
  306. </div>
  307. <div class="clearer"></div>
  308. </div>
  309. <div class="related" role="navigation" aria-label="related navigation">
  310. <h3>Navigation</h3>
  311. <ul>
  312. <li class="right" style="margin-right: 10px">
  313. <a href="../genindex.html" title="General Index"
  314. >index</a></li>
  315. <li class="right" >
  316. <a href="../py-modindex.html" title="Python Module Index"
  317. >modules</a> |</li>
  318. <li class="right" >
  319. <a href="functions.html" title="Built-in Functions"
  320. >next</a> |</li>
  321. <li class="right" >
  322. <a href="index.html" title="The Python Standard Library"
  323. >previous</a> |</li>
  324. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  325. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  326. <li class="switchers">
  327. <div class="language_switcher_placeholder"></div>
  328. <div class="version_switcher_placeholder"></div>
  329. </li>
  330. <li>
  331. </li>
  332. <li id="cpython-language-and-version">
  333. <a href="../index.html">3.12.3 Documentation</a> &#187;
  334. </li>
  335. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  336. <li class="nav-item nav-item-this"><a href="">Introduction</a></li>
  337. <li class="right">
  338. <div class="inline-search" role="search">
  339. <form class="inline-search" action="../search.html" method="get">
  340. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  341. <input type="submit" value="Go" />
  342. </form>
  343. </div>
  344. |
  345. </li>
  346. <li class="right">
  347. <label class="theme-selector-label">
  348. Theme
  349. <select class="theme-selector" oninput="activateTheme(this.value)">
  350. <option value="auto" selected>Auto</option>
  351. <option value="light">Light</option>
  352. <option value="dark">Dark</option>
  353. </select>
  354. </label> |</li>
  355. </ul>
  356. </div>
  357. <div class="footer">
  358. &copy;
  359. <a href="../copyright.html">
  360. Copyright
  361. </a>
  362. 2001-2024, Python Software Foundation.
  363. <br />
  364. This page is licensed under the Python Software Foundation License Version 2.
  365. <br />
  366. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  367. <br />
  368. See <a href="/license.html">History and License</a> for more information.<br />
  369. <br />
  370. The Python Software Foundation is a non-profit corporation.
  371. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  372. <br />
  373. <br />
  374. Last updated on Apr 09, 2024 (13:47 UTC).
  375. <a href="/bugs.html">Found a bug</a>?
  376. <br />
  377. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  378. </div>
  379. </body>
  380. </html>
上海开阖软件有限公司 沪ICP备12045867号-1