我正在尝试通过PythonShell在nodejs中运行python脚本。但是我得到的结果是空的。我不知道python脚本是否返回空值,或者nodejs代码是否有问题。
Nodejs代码
var PythonShell = require('python-shell');
////options for python-shell
PyShellOptions={
mode: 'JSON',
pythonOptions: ['-u'],
scriptPath: 'F:/University/Final Year/FYP/From Shafeeq/ECG-Diagnosis (Python)',//python scripts folder
args: [signal_file,sample_rate,user.meta.age,user.meta.gender,user.meta.height,user.meta.weight]
};
PythonShell.run('main.py', PyShellOptions, function (err, results) {
console.log(err);
if (err) {
console.log(err.message)
}
// results is an array consisting of messages collected during execution
console.log('results: %j', results);
}
Python代码
print(json_content)