이번에는 파이썬 프로그램을 실행해보겠습니다. 실습하려면 파이썬 3가 설치되어 있어야 합니다.
test.py
print('hello python')
spawn.js
const spawn = require('child_process').spawn;
const process = spawn('python3', ['test.py']);
process.stdout.on('data', function(data) {
console.log(data.toString());
}); // 실행 결과
process.stderr.on('data', function(data) {
console.error(data.toString());
}); // 실행 에러