python - PythonShell.run 在结果 nodejs 中返回 null
问题描述
我正在尝试通过 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)
解决方案
推荐阅读
- javascript - ASP.NET 在 jQuery Bundle 上接收 NullReferenceException
- loadrunner - LoadRunner Controller:需要拆分参数文件
- react-native - 试图在反应原生中合并 3*3 图像网格的 4 个表格单元格
- .net-core - 对 IdentityBuilder 类型的引用声称它在 microsoft.aspnetcore.identity 中定义,但找不到
- excel - 为整个工作表运行“一次”循环
- html - AngularJS CheckBox 绑定问题,即使选中了模型值,也未选中复选框
- php - php 从表单提交中删除 URL
- python - TCL Expect脚本嵌入python变量
- r - 如何使用 st_read 从 kml 文件中获取 R 中的坐标
- java - GSON 到 JSON 的转换——长格式和简单日期格式“yyyy-MM-dd'T'HH:mm'Z'”