我正在学习在 python 中使用电子 js,我正在使用python-shell,所以我有以下简单的 python 脚本:
import sys, json
# simple JSON echo script
for line in sys.stdin:
print(json.dumps(json.loads(line)))
Run Code Online (Sandbox Code Playgroud)
在我的 main.js 中:
let {PythonShell} = require('python-shell')
let pyshell = new PythonShell('/home/bassel/electron_app/pyapp/name.py', {mode : 'json'});
pyshell.send({name:"mark"})
pyshell.on('message', function (message) {
// received a message sent from the Python script (a simple "print" statement)
console.log("hi");
});
Run Code Online (Sandbox Code Playgroud)
但是hi
没有打印出来,有什么问题?
python ×1