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.

507 line
33KB

  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="msvcrt — Useful routines from the MS VC++ runtime" />
  7. <meta property="og:type" content="website" />
  8. <meta property="og:url" content="https://docs.python.org/3/library/msvcrt.html" />
  9. <meta property="og:site_name" content="Python documentation" />
  10. <meta property="og:description" content="These functions provide access to some useful capabilities on Windows platforms. Some higher-level modules use these functions to build the Windows implementations of their services. For example, t..." />
  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="These functions provide access to some useful capabilities on Windows platforms. Some higher-level modules use these functions to build the Windows implementations of their services. For example, t..." />
  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>msvcrt — Useful routines from the MS VC++ runtime &#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="winreg — Windows registry access" href="winreg.html" />
  33. <link rel="prev" title="MS Windows Specific Services" href="windows.html" />
  34. <link rel="canonical" href="https://docs.python.org/3/library/msvcrt.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">msvcrt</span></code> — Useful routines from the MS VC++ runtime</a><ul>
  86. <li><a class="reference internal" href="#file-operations">File Operations</a></li>
  87. <li><a class="reference internal" href="#console-i-o">Console I/O</a></li>
  88. <li><a class="reference internal" href="#other-functions">Other Functions</a></li>
  89. </ul>
  90. </li>
  91. </ul>
  92. </div>
  93. <div>
  94. <h4>Previous topic</h4>
  95. <p class="topless"><a href="windows.html"
  96. title="previous chapter">MS Windows Specific Services</a></p>
  97. </div>
  98. <div>
  99. <h4>Next topic</h4>
  100. <p class="topless"><a href="winreg.html"
  101. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">winreg</span></code> — Windows registry access</a></p>
  102. </div>
  103. <div role="note" aria-label="source link">
  104. <h3>This Page</h3>
  105. <ul class="this-page-menu">
  106. <li><a href="../bugs.html">Report a Bug</a></li>
  107. <li>
  108. <a href="https://github.com/python/cpython/blob/main/Doc/library/msvcrt.rst"
  109. rel="nofollow">Show Source
  110. </a>
  111. </li>
  112. </ul>
  113. </div>
  114. </nav>
  115. </div>
  116. </div>
  117. <div class="related" role="navigation" aria-label="related navigation">
  118. <h3>Navigation</h3>
  119. <ul>
  120. <li class="right" style="margin-right: 10px">
  121. <a href="../genindex.html" title="General Index"
  122. accesskey="I">index</a></li>
  123. <li class="right" >
  124. <a href="../py-modindex.html" title="Python Module Index"
  125. >modules</a> |</li>
  126. <li class="right" >
  127. <a href="winreg.html" title="winreg — Windows registry access"
  128. accesskey="N">next</a> |</li>
  129. <li class="right" >
  130. <a href="windows.html" title="MS Windows Specific Services"
  131. accesskey="P">previous</a> |</li>
  132. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  133. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  134. <li class="switchers">
  135. <div class="language_switcher_placeholder"></div>
  136. <div class="version_switcher_placeholder"></div>
  137. </li>
  138. <li>
  139. </li>
  140. <li id="cpython-language-and-version">
  141. <a href="../index.html">3.12.3 Documentation</a> &#187;
  142. </li>
  143. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  144. <li class="nav-item nav-item-2"><a href="windows.html" accesskey="U">MS Windows Specific Services</a> &#187;</li>
  145. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">msvcrt</span></code> — Useful routines from the MS VC++ runtime</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="module-msvcrt">
  171. <span id="msvcrt-useful-routines-from-the-ms-vc-runtime"></span><h1><a class="reference internal" href="#module-msvcrt" title="msvcrt: Miscellaneous useful routines from the MS VC++ runtime. (Windows)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">msvcrt</span></code></a> — Useful routines from the MS VC++ runtime<a class="headerlink" href="#module-msvcrt" title="Link to this heading">¶</a></h1>
  172. <hr class="docutils" />
  173. <p>These functions provide access to some useful capabilities on Windows platforms.
  174. Some higher-level modules use these functions to build the Windows
  175. implementations of their services. For example, the <a class="reference internal" href="getpass.html#module-getpass" title="getpass: Portable reading of passwords and retrieval of the userid."><code class="xref py py-mod docutils literal notranslate"><span class="pre">getpass</span></code></a> module uses
  176. this in the implementation of the <a class="reference internal" href="getpass.html#module-getpass" title="getpass: Portable reading of passwords and retrieval of the userid."><code class="xref py py-func docutils literal notranslate"><span class="pre">getpass()</span></code></a> function.</p>
  177. <p>Further documentation on these functions can be found in the Platform API
  178. documentation.</p>
  179. <p>The module implements both the normal and wide char variants of the console I/O
  180. api. The normal API deals only with ASCII characters and is of limited use
  181. for internationalized applications. The wide char API should be used where
  182. ever possible.</p>
  183. <div class="versionchanged">
  184. <p><span class="versionmodified changed">Changed in version 3.3: </span>Operations in this module now raise <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> where <a class="reference internal" href="exceptions.html#IOError" title="IOError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IOError</span></code></a>
  185. was raised.</p>
  186. </div>
  187. <section id="file-operations">
  188. <span id="msvcrt-files"></span><h2>File Operations<a class="headerlink" href="#file-operations" title="Link to this heading">¶</a></h2>
  189. <dl class="py function">
  190. <dt class="sig sig-object py" id="msvcrt.locking">
  191. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">locking</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">mode</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nbytes</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.locking" title="Link to this definition">¶</a></dt>
  192. <dd><p>Lock part of a file based on file descriptor <em>fd</em> from the C runtime. Raises
  193. <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> on failure. The locked region of the file extends from the
  194. current file position for <em>nbytes</em> bytes, and may continue beyond the end of the
  195. file. <em>mode</em> must be one of the <code class="xref py py-const docutils literal notranslate"><span class="pre">LK_*</span></code> constants listed below. Multiple
  196. regions in a file may be locked at the same time, but may not overlap. Adjacent
  197. regions are not merged; they must be unlocked individually.</p>
  198. <p class="audit-hook">Raises an <a class="reference internal" href="sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">msvcrt.locking</span></code> with arguments <code class="docutils literal notranslate"><span class="pre">fd</span></code>, <code class="docutils literal notranslate"><span class="pre">mode</span></code>, <code class="docutils literal notranslate"><span class="pre">nbytes</span></code>.</p>
  199. </dd></dl>
  200. <dl class="py data">
  201. <dt class="sig sig-object py" id="msvcrt.LK_LOCK">
  202. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LK_LOCK</span></span><a class="headerlink" href="#msvcrt.LK_LOCK" title="Link to this definition">¶</a></dt>
  203. <dt class="sig sig-object py" id="msvcrt.LK_RLCK">
  204. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LK_RLCK</span></span><a class="headerlink" href="#msvcrt.LK_RLCK" title="Link to this definition">¶</a></dt>
  205. <dd><p>Locks the specified bytes. If the bytes cannot be locked, the program
  206. immediately tries again after 1 second. If, after 10 attempts, the bytes cannot
  207. be locked, <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> is raised.</p>
  208. </dd></dl>
  209. <dl class="py data">
  210. <dt class="sig sig-object py" id="msvcrt.LK_NBLCK">
  211. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LK_NBLCK</span></span><a class="headerlink" href="#msvcrt.LK_NBLCK" title="Link to this definition">¶</a></dt>
  212. <dt class="sig sig-object py" id="msvcrt.LK_NBRLCK">
  213. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LK_NBRLCK</span></span><a class="headerlink" href="#msvcrt.LK_NBRLCK" title="Link to this definition">¶</a></dt>
  214. <dd><p>Locks the specified bytes. If the bytes cannot be locked, <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> is
  215. raised.</p>
  216. </dd></dl>
  217. <dl class="py data">
  218. <dt class="sig sig-object py" id="msvcrt.LK_UNLCK">
  219. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LK_UNLCK</span></span><a class="headerlink" href="#msvcrt.LK_UNLCK" title="Link to this definition">¶</a></dt>
  220. <dd><p>Unlocks the specified bytes, which must have been previously locked.</p>
  221. </dd></dl>
  222. <dl class="py function">
  223. <dt class="sig sig-object py" id="msvcrt.setmode">
  224. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">setmode</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">flags</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.setmode" title="Link to this definition">¶</a></dt>
  225. <dd><p>Set the line-end translation mode for the file descriptor <em>fd</em>. To set it to
  226. text mode, <em>flags</em> should be <a class="reference internal" href="os.html#os.O_TEXT" title="os.O_TEXT"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.O_TEXT</span></code></a>; for binary, it should be
  227. <a class="reference internal" href="os.html#os.O_BINARY" title="os.O_BINARY"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.O_BINARY</span></code></a>.</p>
  228. </dd></dl>
  229. <dl class="py function">
  230. <dt class="sig sig-object py" id="msvcrt.open_osfhandle">
  231. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">open_osfhandle</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">handle</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.open_osfhandle" title="Link to this definition">¶</a></dt>
  232. <dd><p>Create a C runtime file descriptor from the file handle <em>handle</em>. The <em>flags</em>
  233. parameter should be a bitwise OR of <a class="reference internal" href="os.html#os.O_APPEND" title="os.O_APPEND"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.O_APPEND</span></code></a>, <a class="reference internal" href="os.html#os.O_RDONLY" title="os.O_RDONLY"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.O_RDONLY</span></code></a>,
  234. and <a class="reference internal" href="os.html#os.O_TEXT" title="os.O_TEXT"><code class="xref py py-const docutils literal notranslate"><span class="pre">os.O_TEXT</span></code></a>. The returned file descriptor may be used as a parameter
  235. to <a class="reference internal" href="os.html#os.fdopen" title="os.fdopen"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fdopen()</span></code></a> to create a file object.</p>
  236. <p class="audit-hook">Raises an <a class="reference internal" href="sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">msvcrt.open_osfhandle</span></code> with arguments <code class="docutils literal notranslate"><span class="pre">handle</span></code>, <code class="docutils literal notranslate"><span class="pre">flags</span></code>.</p>
  237. </dd></dl>
  238. <dl class="py function">
  239. <dt class="sig sig-object py" id="msvcrt.get_osfhandle">
  240. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">get_osfhandle</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="#msvcrt.get_osfhandle" title="Link to this definition">¶</a></dt>
  241. <dd><p>Return the file handle for the file descriptor <em>fd</em>. Raises <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a> if
  242. <em>fd</em> is not recognized.</p>
  243. <p class="audit-hook">Raises an <a class="reference internal" href="sys.html#auditing"><span class="std std-ref">auditing event</span></a> <code class="docutils literal notranslate"><span class="pre">msvcrt.get_osfhandle</span></code> with argument <code class="docutils literal notranslate"><span class="pre">fd</span></code>.</p>
  244. </dd></dl>
  245. </section>
  246. <section id="console-i-o">
  247. <span id="msvcrt-console"></span><h2>Console I/O<a class="headerlink" href="#console-i-o" title="Link to this heading">¶</a></h2>
  248. <dl class="py function">
  249. <dt class="sig sig-object py" id="msvcrt.kbhit">
  250. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">kbhit</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.kbhit" title="Link to this definition">¶</a></dt>
  251. <dd><p>Return <code class="docutils literal notranslate"><span class="pre">True</span></code> if a keypress is waiting to be read.</p>
  252. </dd></dl>
  253. <dl class="py function">
  254. <dt class="sig sig-object py" id="msvcrt.getch">
  255. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">getch</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.getch" title="Link to this definition">¶</a></dt>
  256. <dd><p>Read a keypress and return the resulting character as a byte string.
  257. Nothing is echoed to the console. This call will block if a keypress
  258. is not already available, but will not wait for <kbd class="kbd docutils literal notranslate">Enter</kbd> to be
  259. pressed. If the pressed key was a special function key, this will
  260. return <code class="docutils literal notranslate"><span class="pre">'\000'</span></code> or <code class="docutils literal notranslate"><span class="pre">'\xe0'</span></code>; the next call will return the keycode.
  261. The <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">Control</kbd>-<kbd class="kbd docutils literal notranslate">C</kbd></kbd> keypress cannot be read with this function.</p>
  262. </dd></dl>
  263. <dl class="py function">
  264. <dt class="sig sig-object py" id="msvcrt.getwch">
  265. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">getwch</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.getwch" title="Link to this definition">¶</a></dt>
  266. <dd><p>Wide char variant of <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code class="xref py py-func docutils literal notranslate"><span class="pre">getch()</span></code></a>, returning a Unicode value.</p>
  267. </dd></dl>
  268. <dl class="py function">
  269. <dt class="sig sig-object py" id="msvcrt.getche">
  270. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">getche</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.getche" title="Link to this definition">¶</a></dt>
  271. <dd><p>Similar to <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code class="xref py py-func docutils literal notranslate"><span class="pre">getch()</span></code></a>, but the keypress will be echoed if it represents a
  272. printable character.</p>
  273. </dd></dl>
  274. <dl class="py function">
  275. <dt class="sig sig-object py" id="msvcrt.getwche">
  276. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">getwche</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.getwche" title="Link to this definition">¶</a></dt>
  277. <dd><p>Wide char variant of <a class="reference internal" href="#msvcrt.getche" title="msvcrt.getche"><code class="xref py py-func docutils literal notranslate"><span class="pre">getche()</span></code></a>, returning a Unicode value.</p>
  278. </dd></dl>
  279. <dl class="py function">
  280. <dt class="sig sig-object py" id="msvcrt.putch">
  281. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">putch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">char</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.putch" title="Link to this definition">¶</a></dt>
  282. <dd><p>Print the byte string <em>char</em> to the console without buffering.</p>
  283. </dd></dl>
  284. <dl class="py function">
  285. <dt class="sig sig-object py" id="msvcrt.putwch">
  286. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">putwch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">unicode_char</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.putwch" title="Link to this definition">¶</a></dt>
  287. <dd><p>Wide char variant of <a class="reference internal" href="#msvcrt.putch" title="msvcrt.putch"><code class="xref py py-func docutils literal notranslate"><span class="pre">putch()</span></code></a>, accepting a Unicode value.</p>
  288. </dd></dl>
  289. <dl class="py function">
  290. <dt class="sig sig-object py" id="msvcrt.ungetch">
  291. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">ungetch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">char</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.ungetch" title="Link to this definition">¶</a></dt>
  292. <dd><p>Cause the byte string <em>char</em> to be “pushed back” into the console buffer;
  293. it will be the next character read by <a class="reference internal" href="#msvcrt.getch" title="msvcrt.getch"><code class="xref py py-func docutils literal notranslate"><span class="pre">getch()</span></code></a> or <a class="reference internal" href="#msvcrt.getche" title="msvcrt.getche"><code class="xref py py-func docutils literal notranslate"><span class="pre">getche()</span></code></a>.</p>
  294. </dd></dl>
  295. <dl class="py function">
  296. <dt class="sig sig-object py" id="msvcrt.ungetwch">
  297. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">ungetwch</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">unicode_char</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.ungetwch" title="Link to this definition">¶</a></dt>
  298. <dd><p>Wide char variant of <a class="reference internal" href="#msvcrt.ungetch" title="msvcrt.ungetch"><code class="xref py py-func docutils literal notranslate"><span class="pre">ungetch()</span></code></a>, accepting a Unicode value.</p>
  299. </dd></dl>
  300. </section>
  301. <section id="other-functions">
  302. <span id="msvcrt-other"></span><h2>Other Functions<a class="headerlink" href="#other-functions" title="Link to this heading">¶</a></h2>
  303. <dl class="py function">
  304. <dt class="sig sig-object py" id="msvcrt.heapmin">
  305. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">heapmin</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#msvcrt.heapmin" title="Link to this definition">¶</a></dt>
  306. <dd><p>Force the <code class="xref c c-func docutils literal notranslate"><span class="pre">malloc()</span></code> heap to clean itself up and return unused blocks to
  307. the operating system. On failure, this raises <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>.</p>
  308. </dd></dl>
  309. <dl class="py data">
  310. <dt class="sig sig-object py" id="msvcrt.CRT_ASSEMBLY_VERSION">
  311. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">CRT_ASSEMBLY_VERSION</span></span><a class="headerlink" href="#msvcrt.CRT_ASSEMBLY_VERSION" title="Link to this definition">¶</a></dt>
  312. <dd><p>The CRT Assembly version, from the <code class="file docutils literal notranslate"><span class="pre">crtassem.h</span></code> header file.</p>
  313. </dd></dl>
  314. <dl class="py data">
  315. <dt class="sig sig-object py" id="msvcrt.VC_ASSEMBLY_PUBLICKEYTOKEN">
  316. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">VC_ASSEMBLY_PUBLICKEYTOKEN</span></span><a class="headerlink" href="#msvcrt.VC_ASSEMBLY_PUBLICKEYTOKEN" title="Link to this definition">¶</a></dt>
  317. <dd><p>The VC Assembly public key token, from the <code class="file docutils literal notranslate"><span class="pre">crtassem.h</span></code> header file.</p>
  318. </dd></dl>
  319. <dl class="py data">
  320. <dt class="sig sig-object py" id="msvcrt.LIBRARIES_ASSEMBLY_NAME_PREFIX">
  321. <span class="sig-prename descclassname"><span class="pre">msvcrt.</span></span><span class="sig-name descname"><span class="pre">LIBRARIES_ASSEMBLY_NAME_PREFIX</span></span><a class="headerlink" href="#msvcrt.LIBRARIES_ASSEMBLY_NAME_PREFIX" title="Link to this definition">¶</a></dt>
  322. <dd><p>The Libraries Assembly name prefix, from the <code class="file docutils literal notranslate"><span class="pre">crtassem.h</span></code> header file.</p>
  323. </dd></dl>
  324. </section>
  325. </section>
  326. <div class="clearer"></div>
  327. </div>
  328. </div>
  329. </div>
  330. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  331. <div class="sphinxsidebarwrapper">
  332. <div>
  333. <h3><a href="../contents.html">Table of Contents</a></h3>
  334. <ul>
  335. <li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">msvcrt</span></code> — Useful routines from the MS VC++ runtime</a><ul>
  336. <li><a class="reference internal" href="#file-operations">File Operations</a></li>
  337. <li><a class="reference internal" href="#console-i-o">Console I/O</a></li>
  338. <li><a class="reference internal" href="#other-functions">Other Functions</a></li>
  339. </ul>
  340. </li>
  341. </ul>
  342. </div>
  343. <div>
  344. <h4>Previous topic</h4>
  345. <p class="topless"><a href="windows.html"
  346. title="previous chapter">MS Windows Specific Services</a></p>
  347. </div>
  348. <div>
  349. <h4>Next topic</h4>
  350. <p class="topless"><a href="winreg.html"
  351. title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">winreg</span></code> — Windows registry access</a></p>
  352. </div>
  353. <div role="note" aria-label="source link">
  354. <h3>This Page</h3>
  355. <ul class="this-page-menu">
  356. <li><a href="../bugs.html">Report a Bug</a></li>
  357. <li>
  358. <a href="https://github.com/python/cpython/blob/main/Doc/library/msvcrt.rst"
  359. rel="nofollow">Show Source
  360. </a>
  361. </li>
  362. </ul>
  363. </div>
  364. </div>
  365. <div id="sidebarbutton" title="Collapse sidebar">
  366. <span>«</span>
  367. </div>
  368. </div>
  369. <div class="clearer"></div>
  370. </div>
  371. <div class="related" role="navigation" aria-label="related navigation">
  372. <h3>Navigation</h3>
  373. <ul>
  374. <li class="right" style="margin-right: 10px">
  375. <a href="../genindex.html" title="General Index"
  376. >index</a></li>
  377. <li class="right" >
  378. <a href="../py-modindex.html" title="Python Module Index"
  379. >modules</a> |</li>
  380. <li class="right" >
  381. <a href="winreg.html" title="winreg — Windows registry access"
  382. >next</a> |</li>
  383. <li class="right" >
  384. <a href="windows.html" title="MS Windows Specific Services"
  385. >previous</a> |</li>
  386. <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"/></li>
  387. <li><a href="https://www.python.org/">Python</a> &#187;</li>
  388. <li class="switchers">
  389. <div class="language_switcher_placeholder"></div>
  390. <div class="version_switcher_placeholder"></div>
  391. </li>
  392. <li>
  393. </li>
  394. <li id="cpython-language-and-version">
  395. <a href="../index.html">3.12.3 Documentation</a> &#187;
  396. </li>
  397. <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &#187;</li>
  398. <li class="nav-item nav-item-2"><a href="windows.html" >MS Windows Specific Services</a> &#187;</li>
  399. <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">msvcrt</span></code> — Useful routines from the MS VC++ runtime</a></li>
  400. <li class="right">
  401. <div class="inline-search" role="search">
  402. <form class="inline-search" action="../search.html" method="get">
  403. <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box" />
  404. <input type="submit" value="Go" />
  405. </form>
  406. </div>
  407. |
  408. </li>
  409. <li class="right">
  410. <label class="theme-selector-label">
  411. Theme
  412. <select class="theme-selector" oninput="activateTheme(this.value)">
  413. <option value="auto" selected>Auto</option>
  414. <option value="light">Light</option>
  415. <option value="dark">Dark</option>
  416. </select>
  417. </label> |</li>
  418. </ul>
  419. </div>
  420. <div class="footer">
  421. &copy;
  422. <a href="../copyright.html">
  423. Copyright
  424. </a>
  425. 2001-2024, Python Software Foundation.
  426. <br />
  427. This page is licensed under the Python Software Foundation License Version 2.
  428. <br />
  429. Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
  430. <br />
  431. See <a href="/license.html">History and License</a> for more information.<br />
  432. <br />
  433. The Python Software Foundation is a non-profit corporation.
  434. <a href="https://www.python.org/psf/donations/">Please donate.</a>
  435. <br />
  436. <br />
  437. Last updated on Apr 09, 2024 (13:47 UTC).
  438. <a href="/bugs.html">Found a bug</a>?
  439. <br />
  440. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.2.6.
  441. </div>
  442. </body>
  443. </html>
上海开阖软件有限公司 沪ICP备12045867号-1