Python child process loop over stdin from Node.js parent process
问题 My Node.js parent program executes a child Python process and send to it text data - see here for the implementation. This works ok, the node parent process writes data as: child.stdin.setEncoding('utf-8'); child.stdin.write(data + '\r\n'); child.stdin.end(); the Python child process echoes it back: for line in sys.stdin: ofp.write(line) and it gets back the data to the parent: child.stdout.on('data', function (_data) { var data = Buffer.from(_data, 'utf-8').toString().trim(); res += data; })