PythonJS 是一个用 Python 写的转换器,用来将 Python 代码转成快速的 JavaScript,可运行于 Node.js 平台上。PythonJS 的设计思路的快速和易于集成现有的 JavaScript 代码。
使用方法: 1 | var pythonjs = require( 'python-js' ); |
2 | var pycode = "a = []; a.append('hello'); a.append('world'); print(a)" ; |
3 | var jscode = pythonjs.translator.to_javascript( pycode ); |
4 | eval( pythonjs.runtime.javascript + jscode ); |
JavaScript API: 2 | pythonjs = require( 'python-js' ); |
3 | output = pythonjs.translator.to_javascript( input ); |
4 | output = pythonjs.translator.to_javascript_module( input ); |
5 | output = pythonjs.translator.to_dart( input ); |
6 | output = pythonjs.translator.to_coffee( input ); |
7 | output = pythonjs.translator.to_lua( input ); |
9 | pythonjs.runtime.javascript |
|