LoginSignup
1
1

More than 5 years have passed since last update.

node から pythonを実行して標準出力に表示

Posted at
const spawn = require('child_process').spawn;
const ls = spawn(pythonPath, ['python', OPTION1, OPTION2, ... ], { stdio: 'inherit' })
ls.stdout.on('data', function(data){
    console.log(data.toString());
});
ls.stderr.on('data', function (data) {
    console.log(data.toString());
});
ls.on('exit', function(data){
    console.log(data.toString());
});
ls.on('error', function (err) {
    console.log(err);
});
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1