我有两个可执行文件,例如A.exe,B.exe。是否可以使用python子进程popen将两个可执行文件通过stdin / stdout相互通信:
A = Popen("A.exe",...,stdin=B.stdout, stdout=PIPE)
B = Popen("B.exe",...,stdin=A.stdout, stdout=PIPE) ?
(其中A.exe包含printf / scanf对,而B.exe包含scanf / printf。)
尝试Popen.communicate
它需要一个参数input
与文本发送到子进程并返回一个元组(stdout_data, stderr_data)
(output, error) = A.communicate(input="send to a")