python javascript engine
2010-07-10 0:02

1) Python Wrapper for Google V8 Javascript Engine

项目url:http://code.google.com/p/pyv8/

源代码:svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8-read-only

运行环境:windows,linux

详细使用说明及参考代码:http://zhbmblog.appspot.com/media/agh6aGJtYmxvZ3IMCxIFTWVkaWEY_jYM/PyV8.py

01 import PyV8

02 ctxt = PyV8.JSContext() # create a context with an implicit global object

03 ctxt.enter() # enter the context (also support with statement)

04 ctxt.eval("1+2") # evalute the javascript expression

05 3 # return a native python int

06

07 class Global(PyV8.JSClass): # define a compatible javascript class

08 def hello(self): # define a method

09 print "Hello World"

10

11 ctxt2 = PyV8.JSContext(Global()) # create another context with the global object

12 ctxt2.enter()

13 ctxt2.eval("hello()") # call the global object from javascript

14 Hello World # the output from python script

2)python-spidermonkey

项目url:http://code.google.com/p/python-spidermonkey/

源代码:svn checkout http://python-spidermonkey.googlecode.com/svn/trunk/ python-spidermonkey-read-only

运行环境:OS X,64-bit Ubuntu Linux

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。