python执行js文件

来源:互联网 发布:淘宝怎么搜到假学生证 编辑:程序博客网 时间:2024/05/19 18:45
#!/usr/bin/python# -*- coding: UTF-8 -*-import execjs,os#执行本地自定义的jsprint execjs.compile('function test(){'               'return 5'               '}'               ''               ''               '').call("test")#获取系统的路径paths=os.path.dirname(__file__)print pathsdir=paths+"/js/modules.js"#执行*.js里的文件print execjs.compile(open(dir).read().decode('utf-8')).call('add',3,4)
0 0