python的execjs执行js如何获取js函数的return值
var NodeRSA = require('node-rsa')var fs = require('fs')
function decrypt(crypt_data, pub_path) {
fs.readFile(pub_path, function (err, data) {
var key = new NodeRSA(data);
let rawText = key.decryptPublic(crypt_data, 'utf8');
console.log(rawText);
return rawText;
});
}
python方面如何接收到js函数(decrypt)的返回值呢?
回答:
decrypt
内部异步了, 这个return rawText;
不是decrypt
返回值, 用readFileSync
, 还有就是,说好的代码不要用图片呢!!!
var NodeRSA = require('node-rsa')var fs = require('fs')
function decrypt(crypt_data, pub_path) {
var data = fs.readFileSync(pub_path);
var key = new NodeRSA(data);
let rawText = key.decryptPublic(crypt_data, 'utf8');
console.log(rawText);
return rawText;
}
查看nodejs API
以上是 python的execjs执行js如何获取js函数的return值 的全部内容, 来源链接: utcz.com/a/164507.html