pip install js2py import PyV8ctxt = PyV8.JSContext() #獲取對象ctxt.enter() #調(diào)用js前需要調(diào)用這個函數(shù)result = ctxt.eval(js) #執(zhí)行JSctxt.leave() #執(zhí)行完畢 PyExecJS pip install PyExecJS >>> import execjs >>> execjs.eval("'red yellow blue'.split(' ')") ['red', 'yellow', 'blue'] >>> ctx = execjs.compile(""" ... function add(x, y) { ... return x + y; ... } ... """) >>> ctx.call("add", 1, 2) 3 掃一掃 學習 Python 沒煩惱 |
|