擅长:python、mysql、java
<p>@prasath如果您正在寻找使用communicate()的示例</p>
<pre><code>[root@ichristo_dev]# cat process.py A program that reads stdin for input
#! /usr/bin/python
inp = 0
while(int(inp) != 10):
print "Enter a value: "
inp = raw_input()
print "Got", inp
[root@ichristo_dev]# cat communicate.py
#! /usr/bin/python
from subprocess import Popen, PIPE
p = Popen("./process.py", stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
o, e = p.communicate("10")
print o
[root@ichristo_dev]#./communicate.py
Enter a value:
Got 10
</code></pre>