我有一个简单的 echoprocess.py:
import sys
while True:
data = sys.stdin.read()
sys.stdout.write("Here is the data: " + str(data))
还有一个 parentprocess.py
from subprocess import Popen, PIPE
proc = Popen(["C:/python27/python.exe", "echoprocess.py"],
stdin = PIPE,
sdtout = PIPE)
proc.stdin.write("hello")
print proc.stdout.read()
这只是挂起,直到 echoprocess.py 终止。我想多次与这个子进程通信,而不必再次重新启动它。Windows 上的 Python 子进程模块可以进行这种进程间通信吗?