python - 是否可以用 python 解决运行两个可执行文件并且它们可以相互通信(stdin/stdout)?
问题描述
我有两个可执行文件,例如 A.exe、B.exe。python 子进程是否有可能通过stdin/stdout相互通信两个可执行文件:
A = Popen("A.exe",...,stdin=B.stdout, stdout=PIPE)
B = Popen("B.exe",...,stdin=A.stdout, stdout=PIPE) ?
(其中 A.exe 包含 print/scanf 对,B.exe 包含 scanf/printfs。)
解决方案
尝试Popen.communicate
将input
带有文本的参数发送到子进程并返回一个元组(stdout_data, stderr_data)
(output, error) = A.communicate(input="send to a")
推荐阅读
- node.js - CORS 使用“授权”标头和数据阻止 axios 请求
- javascript - 按下按钮更改图像
- android - 将空的 EditText 转换为整数 Android Studio
- python - Group-by 然后在每组中进行行移位
- java - Camera2 在触摸焦点上。将 TextureView onClick 映射到 sensorArraySize
- android-studio - android studio github 没有更新项目
- tableau-api - 如何计算 Tableau 中 2 个不同工作表之间总计的百分比?
- javascript - 在 javascript 中为 cookie 过期设置午夜
- jasper-reports - 带有 net.sf.jasperreports.export.pdf.field.read.only" value="false" 的 textField 详细信息带未在 Acrobat Reader DC 中呈现
- javascript - 如何在加载 fetch 之前显示加载消息