python - 如何从 Node js 到 python 建立连接?

标签 python node.js

我是 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/

相关文章:

python - 元素出现两次的列表理解

Python sh 模块 - 脚本是否可以请求输入?

python - 重新排列 4d numpy 数组

node.js - then-redis中如何进行rpush操作?

java - websocket 上可能有不同的语言吗?

node.js - Meteor 忘记密码邮件不发送

node.js - 生产环境中的 NodeJS

python - Python 中的简单二维聚类算法

python - 如何从 CMD 切换到 Anaconda Prompt?

javascript - Model.query() 返回 "undefined"错误