python中运行js代码—js2py
import js2py # 实例化一个执行js的环境对象 context_js_obj = js2py.EvalJs() js_str = """ function A(a,b){ return a+b } """ # 传递js_str,执行js context_js_obj.execute(js_str) result = context_js_obj.A(1, 2) print(result) # 创建变量 context_js_obj.num = 30 print(context_js_obj.num)