【PyExecJS】
#编码:utf - 8 #作者:沃克 #,日期:2019-03-13 #,简介:,利用,PyExecJS 调用,js 函数 import execjs JSCode =, " # 39; & # 39; & # 39; ,,,,,,,,,,,function 添加(x, y), { ,,,,,,,,,,,,,,,return x +, y; ,,,,,,,,,,,} & # 39;& # 39;& # 39; 时间=CTX execjs.compile (JSCode) def 测试(): ,,,#,直接使用 ,,,print (execjs.get () .eval (& # 39; 3 + 2 & # 39;)) ,,,#,调函数使用 ,,,print (CTX.call(& # 39;添加# 39;,,3,6)) if __name__ ==, & # 39; __main__ # 39;: ,,,测试()
【节点。js】
#编码:utf - 8 #作者:沃克 #,日期:2019-03-13 #,简介:,直接用,Node.js 调用,js 函数 得到subprocess import  check_output def 测试(): ,,,#,直接调用 ,,,bytesTxt =, check_output (& # 39; node  -e console.log(3 + 2) & # 39;,,超时=100) ,,,print (bytesTxt.decode (& # 39; use utf8 # 39;) .strip ()) ,,,, ,,,#,用,node 直接执行,js 脚本 ,,,bytesTxt =, check_output((& # 39;节点# 39;& # 39;t.js& # 39;,, & # 39; 3 & # 39;,, & # 39; 6 & # 39;],,超时=100) ,,,print (bytesTxt.decode (& # 39; use utf8 # 39;) .strip ()) if __name__ ==, & # 39; __main__ # 39;: ,,,测试()
- <李>
t。李js
>function 添加(x, y), { ,,,return x +, y; } var args =, process.argv.splice (2); console.log(添加(方法(args[0]),方法(args [1]))),
【节点。js指定函数】
#编码:utf - 8 #作者:沃克 #,日期:2019-03-14 #,简介:,直接用,Node.js 调用指定,js 函数 得到subprocess import  check_output JSCode =, " # 39; & # 39; & # 39; ,,,,,,,,,,,function 添加(x, y), { ,,,,,,,,,,,,,,,return x +, y; ,,,,,,,,,,,} ,,,,,,,,,,, ,,,,,,,,,,,function 子(x, y), { ,,,,,,,,,,,,,,,return x 作用;y; ,,,,,,,,,,,} ,,,,,,,,,,, ,,,,,,,,,,,function foo (x), { ,,,,,,,,,,,,,,,return x; ,,,,,,,,,,,} & # 39;& # 39;& # 39; def 测试(): ,,,jscode =, jscode +, & # 39; process.stdout.write(添加(3,2).toString ()) & # 39; ,,,rtn =, check_output(& # 39;节点# 39;,,输入=jscode, universal_newlines=True,,超时=100) ,,,print(研制 if __name__ ==, & # 39; __main__ # 39;: ,,,测试()
【相关阅读】
- <李>
Python之系统交互(子流程)
沃克* * * * * *