【发布时间】:2021-12-12 15:02:34
【问题描述】:
我在 nodejs 中运行 python 脚本。有用 。但我想保持打开状态,然后多次从 nodejs 调用 def 函数。我该怎么做。
nodejs
let {PythonShell}=require( 'python-shell');
let py=PythonShell.run('test.py', null, function (err, results) {
console.log('results: %j', results);
});
test.py
print('start');
def hello():
print ('hello');
【问题讨论】:
-
你可以多次运行你的nodejs代码。把它放在一个函数中,然后调用它
标签: javascript python node.js