【发布时间】:2017-01-13 05:43:06
【问题描述】:
成功的python管道标准输入,只输出一次这个源
main.py
import subprocess from subprocess import PIPE, STDOUT
player_pipe = subprocess.Popen(["source\call.py", 'arg1'], stdin=PIPE,
stdout=PIPE, stderr=STDOUT, shell=True)
player_pipe.stdin.write("Send Msg\n")
get_stdout = player_pipe.stdout.readline()
print("[Get Msg]" + get_stdout)
player_pipe.kill()
player_pipe.wait()
调用.py
import sys
getMsg = raw_input()
print getMsg
但我想要两次或更长时间的标准输入,输出
所以更新源,但它不起作用
这个来源有什么问题
main.py(更新-不起作用)
import subprocess from subprocess import PIPE, STDOUT
player_pipe = subprocess.Popen(["source\call.py", 'arg1'], stdin=PIPE,
stdout=PIPE, stderr=STDOUT, shell=True)
player_pipe.stdin.write("Send Msg\n")
get_stdout = player_pipe.stdout.readline()
print("[Get Msg]" + get_stdout)
player_pipe.stdin.write("Send Msg2\n")
get_stdout = player_pipe.stdout.readline()
print("[Get Msg]" + get_stdout)
player_pipe.kill()
player_pipe.wait()
call.py(update-not work)
import sys
getMsg = raw_input()
print getMsg
getMsg2 = raw_input()
print getMsg2
:D
【问题讨论】: