安装
pip install execjs
python 中调用 js 代码
有一个 js 文件 test.js
import execjs
with open(r'flag生成.js') as f:
flag = f.read()
flag = execjs.compile(flag)
flag = flag.call('Flag')
return flag
- compile() 编译打开的 js 文件代码
- call()调用 js 的函数,第一个参数为 函数名,第二个为参数