浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

python javascript engine_pythonercn的空间_百度空间

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

posted on 2012-03-31 15:04  lexus  阅读(378)  评论(0编辑  收藏  举报