2024-06-20 15:15:15 发布
网友
我想发送给python a节点.js变量,用python修改它并重新发送到节点.js,这是我的代码示例: Python
def change_input(variable): variable*=5 #now send variable to node.js
现在,js代码:
如何在python和javascript之间循环变量?在
这里有一种方法,通过在节点内生成一个子python进程来实现。在
在测试.js公司名称:
const { spawn } = require('child_process'); const p = spawn('python', ['yourscript.py', '1']); p.stdout.on('data', (data) => { console.log(`stdout: ${data}`); });
在你的脚本.py在
运行node ./test.js的输出:
node ./test.js
stdout: hello from python: 4
目录布局
➜ test tree . ├── test.js └── yourscript.py 0 directories, 2 files
相关:
这里有一种方法,通过在节点内生成一个子python进程来实现。在
在测试.js公司名称:
在你的脚本.py在
^{pr2}$运行
node ./test.js
的输出:目录布局
相关:
相关问题 更多 >
编程相关推荐