我尝试用spawn启动一个python脚本,没有参数它正在工作:
toExecute="myscript.py";
const ls = spawn('python',toExecute);
ls.stdout.on('data', (data) => {
...
});
但是当我尝试传递其他参数时,它不再起作用了:
const ls = spawn('python',[toExecute, "test"]);
我收到以下错误:
[red] Uncaught Exception: 4 Aug 13:40:59 - SyntaxError: Unexpected
token u
at Object.parse (native)
at Socket.<anonymous> (/home/....js:29:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at Pipe.onread (net.js:523:20)