gooderp18绿色标准版
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

466 lines
29KB

  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="termios — POSIX style tty control" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/termios.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="This module provides an interface to the POSIX calls for tty I/O control. For a complete description of these calls, see termios(3) Unix manual page. It is only available for those Unix versions th..." />
  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="This module provides an interface to the POSIX calls for tty I/O control. For a complete description of these calls, see termios(3) Unix manual page. It is only available for those Unix versions th..." />
  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>termios — POSIX style tty control &#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="tty — Terminal control functions" href="tty.html" />
  33. <link rel="prev" title="grp — The group database" href="grp.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/termios.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">termios</span></code> — POSIX style tty control</a><ul>
  86. <li><a class="reference internal" href="#example">Example</a></li>
  87. </ul>
  88. </li>
  89. </ul>
  90. </div>
  91. <div>
  92. <h4>Previous topic</h4>
  93. <p class="topless"><a href="grp.html"
  94. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">grp</span></code> — The group database</a></p>
  95. </div>
  96. <div>
  97. <h4>Next topic</h4>
  98. <p class="topless"><a href="tty.html"
  99. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tty</span></code> — Terminal control functions</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/termios.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="tty.html" title="tty — Terminal control functions"
  126. accesskey="N">next</a> |</li>
  127. <li class="right" >
  128. <a href="grp.html" title="grp — The group database"
  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="unix.html" accesskey="U">Unix Specific Services</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">termios</span></code> — POSIX style tty control</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-termios">
  169. <span id="termios-posix-style-tty-control"></span><h1><a class="reference internal" href="#module-termios" title="termios: POSIX style tty control. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">termios</span></code></a> — POSIX style tty control<a class="headerlink" href="#module-termios" title="Link to this heading">¶</a></h1>
  170. <hr class="docutils" id="index-0" />
  171. <p>This module provides an interface to the POSIX calls for tty I/O control. For a
  172. complete description of these calls, see <em class="manpage"><a class="manpage reference external" href="https://manpages.debian.org/termios(3)">termios(3)</a></em> Unix manual
  173. page. It is only available for those Unix versions that support POSIX
  174. <em>termios</em> style tty I/O control configured during installation.</p>
  175. <div class="availability docutils container">
  176. <p><a class="reference internal" href="intro.html#availability"><span class="std std-ref">Availability</span></a>: Unix.</p>
  177. </div>
  178. <p>All functions in this module take a file descriptor <em>fd</em> as their first
  179. argument. This can be an integer file descriptor, such as returned by
  180. <code class="docutils literal notranslate"><span class="pre">sys.stdin.fileno()</span></code>, or a <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file object</span></a>, such as <code class="docutils literal notranslate"><span class="pre">sys.stdin</span></code> itself.</p>
  181. <p>This module also defines all the constants needed to work with the functions
  182. provided here; these have the same name as their counterparts in C. Please
  183. refer to your system documentation for more information on using these terminal
  184. control interfaces.</p>
  185. <p>The module defines the following functions:</p>
  186. <dl class="py function">
  187. <dt class="sig sig-object py" id="termios.tcgetattr">
  188. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcgetattr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcgetattr" title="Link to this definition">¶</a></dt>
  189. <dd><p>Return a list containing the tty attributes for file descriptor <em>fd</em>, as
  190. follows: <code class="docutils literal notranslate"><span class="pre">[iflag,</span> <span class="pre">oflag,</span> <span class="pre">cflag,</span> <span class="pre">lflag,</span> <span class="pre">ispeed,</span> <span class="pre">ospeed,</span> <span class="pre">cc]</span></code> where <em>cc</em> is a
  191. list of the tty special characters (each a string of length 1, except the
  192. items with indices <code class="xref py py-const docutils literal notranslate"><span class="pre">VMIN</span></code> and <code class="xref py py-const docutils literal notranslate"><span class="pre">VTIME</span></code>, which are integers when
  193. these fields are defined). The interpretation of the flags and the speeds as
  194. well as the indexing in the <em>cc</em> array must be done using the symbolic
  195. constants defined in the <a class="reference internal" href="#module-termios" title="termios: POSIX style tty control. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">termios</span></code></a> module.</p>
  196. </dd></dl>
  197. <dl class="py function">
  198. <dt class="sig sig-object py" id="termios.tcsetattr">
  199. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcsetattr</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">when</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">attributes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcsetattr" title="Link to this definition">¶</a></dt>
  200. <dd><p>Set the tty attributes for file descriptor <em>fd</em> from the <em>attributes</em>, which is
  201. a list like the one returned by <a class="reference internal" href="#termios.tcgetattr" title="termios.tcgetattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">tcgetattr()</span></code></a>. The <em>when</em> argument
  202. determines when the attributes are changed:</p>
  203. <dl class="py data">
  204. <dt class="sig sig-object py" id="termios.TCSANOW">
  205. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">TCSANOW</span></span><a class="headerlink" href="#termios.TCSANOW" title="Link to this definition">¶</a></dt>
  206. <dd><p>Change attributes immediately.</p>
  207. </dd></dl>
  208. <dl class="py data">
  209. <dt class="sig sig-object py" id="termios.TCSADRAIN">
  210. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">TCSADRAIN</span></span><a class="headerlink" href="#termios.TCSADRAIN" title="Link to this definition">¶</a></dt>
  211. <dd><p>Change attributes after transmitting all queued output.</p>
  212. </dd></dl>
  213. <dl class="py data">
  214. <dt class="sig sig-object py" id="termios.TCSAFLUSH">
  215. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">TCSAFLUSH</span></span><a class="headerlink" href="#termios.TCSAFLUSH" title="Link to this definition">¶</a></dt>
  216. <dd><p>Change attributes after transmitting all queued output and
  217. discarding all queued input.</p>
  218. </dd></dl>
  219. </dd></dl>
  220. <dl class="py function">
  221. <dt class="sig sig-object py" id="termios.tcsendbreak">
  222. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcsendbreak</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">duration</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcsendbreak" title="Link to this definition">¶</a></dt>
  223. <dd><p>Send a break on file descriptor <em>fd</em>. A zero <em>duration</em> sends a break for
  224. 0.25–0.5 seconds; a nonzero <em>duration</em> has a system dependent meaning.</p>
  225. </dd></dl>
  226. <dl class="py function">
  227. <dt class="sig sig-object py" id="termios.tcdrain">
  228. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcdrain</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcdrain" title="Link to this definition">¶</a></dt>
  229. <dd><p>Wait until all output written to file descriptor <em>fd</em> has been transmitted.</p>
  230. </dd></dl>
  231. <dl class="py function">
  232. <dt class="sig sig-object py" id="termios.tcflush">
  233. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcflush</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">queue</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcflush" title="Link to this definition">¶</a></dt>
  234. <dd><p>Discard queued data on file descriptor <em>fd</em>. The <em>queue</em> selector specifies
  235. which queue: <code class="xref py py-const docutils literal notranslate"><span class="pre">TCIFLUSH</span></code> for the input queue, <code class="xref py py-const docutils literal notranslate"><span class="pre">TCOFLUSH</span></code> for the
  236. output queue, or <code class="xref py py-const docutils literal notranslate"><span class="pre">TCIOFLUSH</span></code> for both queues.</p>
  237. </dd></dl>
  238. <dl class="py function">
  239. <dt class="sig sig-object py" id="termios.tcflow">
  240. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcflow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">action</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcflow" title="Link to this definition">¶</a></dt>
  241. <dd><p>Suspend or resume input or output on file descriptor <em>fd</em>. The <em>action</em>
  242. argument can be <code class="xref py py-const docutils literal notranslate"><span class="pre">TCOOFF</span></code> to suspend output, <code class="xref py py-const docutils literal notranslate"><span class="pre">TCOON</span></code> to restart
  243. output, <code class="xref py py-const docutils literal notranslate"><span class="pre">TCIOFF</span></code> to suspend input, or <code class="xref py py-const docutils literal notranslate"><span class="pre">TCION</span></code> to restart input.</p>
  244. </dd></dl>
  245. <dl class="py function">
  246. <dt class="sig sig-object py" id="termios.tcgetwinsize">
  247. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcgetwinsize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcgetwinsize" title="Link to this definition">¶</a></dt>
  248. <dd><p>Return a tuple <code class="docutils literal notranslate"><span class="pre">(ws_row,</span> <span class="pre">ws_col)</span></code> containing the tty window size for file
  249. descriptor <em>fd</em>. Requires <code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCGWINSZ</span></code> or
  250. <code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCGSIZE</span></code>.</p>
  251. <div class="versionadded">
  252. <p><span class="versionmodified added">New in version 3.11.</span></p>
  253. </div>
  254. </dd></dl>
  255. <dl class="py function">
  256. <dt class="sig sig-object py" id="termios.tcsetwinsize">
  257. <span class="sig-prename descclassname"><span class="pre">termios.</span></span><span class="sig-name descname"><span class="pre">tcsetwinsize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fd</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">winsize</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#termios.tcsetwinsize" title="Link to this definition">¶</a></dt>
  258. <dd><p>Set the tty window size for file descriptor <em>fd</em> from <em>winsize</em>, which is
  259. a two-item tuple <code class="docutils literal notranslate"><span class="pre">(ws_row,</span> <span class="pre">ws_col)</span></code> like the one returned by
  260. <a class="reference internal" href="#termios.tcgetwinsize" title="termios.tcgetwinsize"><code class="xref py py-func docutils literal notranslate"><span class="pre">tcgetwinsize()</span></code></a>. Requires at least one of the pairs
  261. (<code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCGWINSZ</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCSWINSZ</span></code>);
  262. (<code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCGSIZE</span></code>, <code class="xref py py-const docutils literal notranslate"><span class="pre">termios.TIOCSSIZE</span></code>) to be defined.</p>
  263. <div class="versionadded">
  264. <p><span class="versionmodified added">New in version 3.11.</span></p>
  265. </div>
  266. </dd></dl>
  267. <div class="admonition seealso">
  268. <p class="admonition-title">See also</p>
  269. <dl class="simple">
  270. <dt>Module <a class="reference internal" href="tty.html#module-tty" title="tty: Utility functions that perform common terminal control operations. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tty</span></code></a></dt><dd><p>Convenience functions for common terminal control operations.</p>
  271. </dd>
  272. </dl>
  273. </div>
  274. <section id="example">
  275. <span id="termios-example"></span><h2>Example<a class="headerlink" href="#example" title="Link to this heading">¶</a></h2>
  276. <p>Here’s a function that prompts for a password with echoing turned off. Note the
  277. technique using a separate <a class="reference internal" href="#termios.tcgetattr" title="termios.tcgetattr"><code class="xref py py-func docutils literal notranslate"><span class="pre">tcgetattr()</span></code></a> call and a <a class="reference internal" href="../reference/compound_stmts.html#try"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">try</span></code></a> …
  278. <a class="reference internal" href="../reference/compound_stmts.html#finally"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">finally</span></code></a> statement to ensure that the old tty attributes are restored
  279. exactly no matter what happens:</p>
  280. <div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">getpass</span><span class="p">(</span><span class="n">prompt</span><span class="o">=</span><span class="s2">&quot;Password: &quot;</span><span class="p">):</span>
  281. <span class="kn">import</span> <span class="nn">termios</span><span class="o">,</span> <span class="nn">sys</span>
  282. <span class="n">fd</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">fileno</span><span class="p">()</span>
  283. <span class="n">old</span> <span class="o">=</span> <span class="n">termios</span><span class="o">.</span><span class="n">tcgetattr</span><span class="p">(</span><span class="n">fd</span><span class="p">)</span>
  284. <span class="n">new</span> <span class="o">=</span> <span class="n">termios</span><span class="o">.</span><span class="n">tcgetattr</span><span class="p">(</span><span class="n">fd</span><span class="p">)</span>
  285. <span class="n">new</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">=</span> <span class="n">new</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">&amp;</span> <span class="o">~</span><span class="n">termios</span><span class="o">.</span><span class="n">ECHO</span> <span class="c1"># lflags</span>
  286. <span class="k">try</span><span class="p">:</span>
  287. <span class="n">termios</span><span class="o">.</span><span class="n">tcsetattr</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="n">termios</span><span class="o">.</span><span class="n">TCSADRAIN</span><span class="p">,</span> <span class="n">new</span><span class="p">)</span>
  288. <span class="n">passwd</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="n">prompt</span><span class="p">)</span>
  289. <span class="k">finally</span><span class="p">:</span>
  290. <span class="n">termios</span><span class="o">.</span><span class="n">tcsetattr</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="n">termios</span><span class="o">.</span><span class="n">TCSADRAIN</span><span class="p">,</span> <span class="n">old</span><span class="p">)</span>
  291. <span class="k">return</span> <span class="n">passwd</span>
  292. </pre></div>
  293. </div>
  294. </section>
  295. </section>
  296. <div class="clearer"></div>
  297. </div>
  298. </div>
  299. </div>
  300. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  301. <div class="sphinxsidebarwrapper">
  302. <div>
  303. <h3><a href="../contents.html">Table of Contents</a></h3>
  304. <ul>
  305. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">termios</span></code> — POSIX style tty control</a><ul>
  306. <li><a class="reference internal" href="#example">Example</a></li>
  307. </ul>
  308. </li>
  309. </ul>
  310. </div>
  311. <div>
  312. <h4>Previous topic</h4>
  313. <p class="topless"><a href="grp.html"
  314. title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">grp</span></code> — The group database</a></p>
  315. </div>
  316. <div>
  317. <h4>Next topic</h4>
  318. <p class="topless"><a href="tty.html"
  319. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">tty</span></code> — Terminal control functions</a></p>
  320. </div>
  321. <div role="note" aria-label="source link">
  322. <h3>This Page</h3>
  323. <ul class="this-page-menu">
  324. <li><a href="../bugs.html">Report a Bug</a></li>
  325. <li>
  326. <a href="https://github.com/python/cpython/blob/main/Doc/library/termios.rst"
  327. rel="nofollow">Show Source
  328. </a>
  329. </li>
  330. </ul>
  331. </div>
  332. </div>
  333. <div id="sidebarbutton" title="Collapse sidebar">
  334. <span>«</span>
  335. </div>
  336. </div>
  337. <div class="clearer"></div>
  338. </div>
  339. <div class="related" role="navigation" aria-label="related navigation">
  340. <h3>Navigation</h3>
  341. <ul>
  342. <li class="right" style="margin-right: 10px">
  343. <a href="../genindex.html" title="General Index"
  344. >index</a></li>
  345. <li class="right" >
  346. <a href="../py-modindex.html" title="Python Module Index"
  347. >modules</a> |</li>
  348. <li class="right" >
  349. <a href="tty.html" title="tty — Terminal control functions"
  350. >next</a> |</li>
  351. <li class="right" >
  352. <a href="grp.html" title="grp — The group database"
  353. >previous</a> |</li>
  354. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  355. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  356. <li class="switchers">
  357. <div class="language_switcher_placeholder"></div>
  358. <div class="version_switcher_placeholder"></div>
  359. </li>
  360. <li>
  361. </li>
  362. <li id="cpython-language-and-version">
  363. <a href="../index.html">3.12.3 Documentation</a> &#187;
  364. </li>
  365. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  366. <li class="nav-item nav-item-2"><a href="unix.html" >Unix Specific Services</a> &#187;</li>
  367. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">termios</span></code> — POSIX style tty control</a></li>
  368. <li class="right">
  369. <div class="inline-search" role="search">
  370. <form class="inline-search" action="../search.html" method="get">
  371. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  372. <input type="submit" value="Go" />
  373. </form>
  374. </div>
  375. |
  376. </li>
  377. <li class="right">
  378. <label class="theme-selector-label">
  379. Theme
  380. <select class="theme-selector" oninput="activateTheme(this.value)">
  381. <option value="auto" selected>Auto</option>
  382. <option value="light">Light</option>
  383. <option value="dark">Dark</option>
  384. </select>
  385. </label> |</li>
  386. </ul>
  387. </div>
  388. <div class="footer">
  389. &copy;
  390. <a href="../copyright.html">
  391. Copyright
  392. </a>
  393. 2001-2024, Python Software Foundation.
  394. <br />
  395. This page is licensed under the Python Software Foundation License Version 2.
  396. <br />
  397. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  398. <br />
  399. See <a href="/license.html">History and License</a> for more information.<br />
  400. <br />
  401. The Python Software Foundation is a non-profit corporation.
  402. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  403. <br />
  404. <br />
  405. Last updated on Apr 09, 2024 (13:47 UTC).
  406. <a href="/bugs.html">Found a bug</a>?
  407. <br />
  408. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  409. </div>
  410. </body>
  411. </html>
上海开阖软件有限公司 沪ICP备12045867号-1