Application
适用于Node.js实现的小程序,在Node.js中创建一个进程供Python使用
Code added to Node.js
var exec = require('child_process').exec;
var arg1 = para1;
var arg2 = para2;
var filename = 'pyscript.py'
exec('python'+' '+filename+' '+arg1+' '+arg2,function(err,stdout,stderr){
if(stdout){console.log("py success", stdout);}
if(err){console.log("py fail", err);}
})
Code of Python
import sys
python_script_name = sys.argv[0]
para1 = sys.argv[1]
print (para1)
供参考:Node.js中调用其他脚本
http://www.cnblogs.com/zhouji…