我是 Node js 和 python 的新手,只是想将 Node js 与 python 进行通信,反之亦然。我需要在 Web 浏览器上运行和托管的简单脚本,以便在 Node js 中执行 python 脚本。只是想在托管环境中运行 Node js 脚本后将一条消息从 Node JS 传输到 Python。
最佳答案
您需要使用系统调用从nodejs执行python代码。
var exec = require('child_process').exec;
var cmd = 'python myscript.py';
exec(cmd, function(error, stdout, stderr) {
// command output is in stdout (This the output from the python script that you might use
});
关于python - 如何从 Node js 到 python 建立连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39889395/