python3与子进程通讯,怎么传输值
app.py:
import subprocess
p = subprocess.Popen("test2.exe", stdin = subprocess.PIPE,stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = False)
p.stdin.write("3\n")
p.stdin.write("4\n")
print(p.stdout.read())
#include <iostream>
using namespace std;
int main(int argc, const char *artv[])
{
int x, y;
cout << "input x:"<< endl;
cin >> x;
cout << "input y:"<< endl;
cin >> y;
cout << x << " + " << y << " = " << x + y << endl;
return 0;
}