1.pip3 install PyExecJS
2.需要安装一个JS运行环境:Node.js 或 PhantomJS。
import execjs
# Init environment
node = execjs.get()
# Compile javascript(自己需要调用方法的js文件)
file = 'open_id.js'
ctx = node.compile(open(file).read())
# Execution method
js = 'createUuid()'
params = ctx.eval(js)
print(params)