擅长:python、mysql、java
<p>直接将输入传递给来自docs的通信<a href="https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate" rel="nofollow">https://docs.python.org/2/library/subprocess.html#subprocess.Popen.communicate</a></p>
<blockquote>
<p>Interact with process: Send data to stdin. Read data from stdout and
stderr, until end-of-file is reached. Wait for process to terminate.
The optional input argument should be a string to be sent to the child
process, or None, if no data should be sent to the child.</p>
</blockquote>
<p>示例:</p>
<pre><code>cmd = ['some', 'list', 'of', 'commands']
fp = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = fp.communicate('\n')
</code></pre>