V8 的 Python 封装 PyV8

码农软件 · 软件分类 · 浏览器/JS引擎 · 2019-04-05 15:29:16

软件介绍

PyV8 是 V8 引擎的 Python 语言封装,这是 Python 和 JavaScript 对象之间的桥,支持在 Python 脚本中调用 V8 引擎。

>>> import PyV8
>>> ctxt = PyV8.JSContext()          # create a context with an implicit global object
>>> ctxt.enter()                     # enter the context (also support with statement)
>>> ctxt.eval("1+2")                 # evalute the javascript expression
3                                    # return a native python int
>>> class Global(PyV8.JSClass):      # define a compatible javascript class
...   def hello(self):               # define a method
...     print "Hello World"    
...
>>> ctxt2 = PyV8.JSContext(Global()) # create another context with the global object
>>> ctxt2.enter()                    
>>> ctxt2.eval("hello()")            # call the global object from javascript
Hello World                          # the output from python script


本文地址:https://codercto.com/soft/d/2921.html

码农翻身

码农翻身

刘欣 / 电子工业出版社 / 2018-6-1 / 69.00元

《码农翻身》用故事的方式讲解了软件编程的若干重要领域,侧重于基础性、原理性的知识。 《码农翻身》分为6章。第1章讲述计算机的基础知识;第2章侧重讲解Java的基础知识;第3章偏重Web后端编程;第4章讲解代码管理的本质;第5章讲述了JavaScript的历史、Node.js的原理、程序的链接、命令式和声明式编程的区别,以及作者十多年来使用各种编程语言的感受;第6章是作者的经验总结和心得体会,......一起来看看 《码农翻身》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码