0%

python | PyExecJS

使用 python 执行 js 代码。


参考资料


PyExecJS


安装


pip install PyExecJS

使用


1
2
3
4
5
6
7
8
9
import execjs
execjs.eval("'red yellow blue'.split(' ')")
['red', 'yellow', 'blue']
ctx = execjs.compile("""
function add(x, y) {
return x + y;
}
""")
ctx.call("add", 1, 2)

关于更多细节,请参考官方文档。

请我喝杯咖啡吧~