PyV8是V8引擎的Pytho语言封装,这是Pytho和JavaScript对象之间的桥,支持在Pytho脚本中调用V8引擎。
>>> import PyV8>>> ctxt = PyV8.JSCotext() # create a cotext with a implicit global object>>> ctxt.eter() # eter the cotext (also support with statemet)>>> ctxt.eval("1+2") # evalute the javascript expressio3 # retur a ative pytho it>>> class Global(PyV8.JSClass): # defie a compatible javascript class... def hello(self): # defie a method... prit "Hello World" ...>>> ctxt2 = PyV8.JSCotext(Global()) # create aother cotext with the global object>>> ctxt2.eter() >>> ctxt2.eval("hello()") # call the global object from javascriptHello World # the output from pytho script点击空白处退出提示
评论