⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-popen2.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>6.8 popen2 -- Subprocesses with accessible I/O streams</title>
<META NAME="description" CONTENT="6.8 popen2 -- Subprocesses with accessible I/O streams">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-time.html" tppabs="http://www.python.org/doc/current/lib/module-time.html">
<LINK REL="previous" href="module-filecmp.html" tppabs="http://www.python.org/doc/current/lib/module-filecmp.html">
<LINK REL="up" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">
<LINK REL="next" href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="dircmp-objects.html" tppabs="http://www.python.org/doc/current/lib/dircmp-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="dircmp-objects.html" tppabs="http://www.python.org/doc/current/lib/dircmp-objects.html">6.7.1 The dircmp class</A>
<b class="navlabel">Up:</b> <a class="sectref" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b> <a class="sectref" href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html">6.8.1 Popen3 and Popen4</A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION008800000000000000000">
6.8 <tt class="module">popen2</tt> --
         Subprocesses with accessible I/O streams</A>
</H1>

<P>
  
<p class='availability'>Availability: <span
 class='platform'>Unix, Windows</span>.</p>

<P>
This module allows you to spawn processes and connect to their
input/output/error pipes and obtain their return codes under
Unix and Windows.

<P>
Note that starting with Python 2.0, this functionality is available
using functions from the <tt class='module'><a href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">os</a></tt> module which have the same
names as the factory functions here, but the order of the return
values is more intuitive in the <tt class='module'><a href="module-os.html" tppabs="http://www.python.org/doc/current/lib/module-os.html">os</a></tt> module variants.

<P>
The primary interface offered by this module is a trio of factory
functions.  For each of these, if <var>bufsize</var> is specified, 
it specifies the buffer size for the I/O pipes.  <var>mode</var>, if
provided, should be the string <code>'b'</code> or <code>'t'</code>; on Windows
this is needed to determine whether the file objects should be opened
in binary or text mode.  The default value for <var>mode</var> is
<code>'t'</code>.

<P>
<dl><dt><b><a name='l2h-1118'><tt class='function'>popen2</tt></a></b> (<var>cmd</var><big>[</big><var>, bufsize</var><big>[</big><var>, mode</var><big>]</big><big>]</big>)
<dd>
Executes <var>cmd</var> as a sub-process.  Returns the file objects
<code>(<var>child_stdout</var>, <var>child_stdin</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-1119'><tt class='function'>popen3</tt></a></b> (<var>cmd</var><big>[</big><var>, bufsize</var><big>[</big><var>, mode</var><big>]</big><big>]</big>)
<dd>
Executes <var>cmd</var> as a sub-process.  Returns the file objects
<code>(<var>child_stdout</var>, <var>child_stdin</var>, <var>child_stderr</var>)</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-1120'><tt class='function'>popen4</tt></a></b> (<var>cmd</var><big>[</big><var>, bufsize</var><big>[</big><var>, mode</var><big>]</big><big>]</big>)
<dd>
Executes <var>cmd</var> as a sub-process.  Returns the file objects
<code>(<var>child_stdout_and_stderr</var>, <var>child_stdin</var>)</code>.

New in version 2.0.

</dl>

<P>
On Unix, a class defining the objects returned by the factory
functions is also available.  These are not used for the Windows
implementation, and are not available on that platform.

<P>
<dl><dt><b><a name='l2h-1121'><tt class='class'>Popen3</tt></a></b> (<var>cmd</var><big>[</big><var>, capturestderr</var><big>[</big><var>, bufsize</var><big>]</big><big>]</big>)
<dd>
This class represents a child process.  Normally, <tt class="class">Popen3</tt>
instances are created using the <tt class="function">popen2()</tt> and
<tt class="function">popen3()</tt> factory functions described above.

<P>
If not using one off the helper functions to create <tt class="class">Popen3</tt>
objects, the parameter <var>cmd</var> is the shell command to execute in a
sub-process.  The <var>capturestderr</var> flag, if true, specifies that
the object should capture standard error output of the child process.
The default is false.  If the <var>bufsize</var> parameter is specified, it
specifies the size of the I/O buffers to/from the child process.
</dl>

<P>
<dl><dt><b><a name='l2h-1122'><tt class='class'>Popen4</tt></a></b> (<var>cmd</var><big>[</big><var>, bufsize</var><big>]</big>)
<dd>
Similar to <tt class="class">Popen3</tt>, but always captures standard error into the
same file object as standard output.  These are typically created
using <tt class="function">popen4()</tt>.

New in version 2.0.

</dl>

<P>

<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html2347"
  href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html">6.8.1 Popen3 and Popen4 Objects </A>
</UL>
<!--End of Table of Child-Links-->

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="dircmp-objects.html" tppabs="http://www.python.org/doc/current/lib/dircmp-objects.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
  alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="dircmp-objects.html" tppabs="http://www.python.org/doc/current/lib/dircmp-objects.html">6.7.1 The dircmp class</A>
<b class="navlabel">Up:</b> <a class="sectref" href="allos.html" tppabs="http://www.python.org/doc/current/lib/allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b> <a class="sectref" href="popen3-objects.html" tppabs="http://www.python.org/doc/current/lib/popen3-objects.html">6.8.1 Popen3 and Popen4</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -