小编mar*_*ark的帖子

Python不打印输出

我正在学习在 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

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1