一 ,检查环境
>>> import execjs
>>> execjs.get().name
'Node.js (V8)'
>>>
二,选择不同的引擎
长期使用
os.environ["EXECJS_RUNTIME"]="Node"
临时使用
import execjs.runtime_names
node=execjs.get(execjs.runtime_names.Node)
使用示例
import execjs
jstext ='''function hello(str){return str}'''
ctx=execjs.compile(jstext) # 编译js代码
a = ctx.call("hello", "hello world") # 多个函数==》 打逗号加
print(a)