python 运行js代码

来源:互联网 发布:iphone6s数据漫游 编辑:程序博客网 时间:2024/05/10 12:29

python 运行js 代码

# -*- coding: utf-8 -*-import execjsctx = execjs.compile("""            function text(content){                return "http://guides.okmk.com/search.html?k=" + escape(content)                }            """)searchKey = ctx.call("text", "苏州")print searchKey

如上所示 以先编译后运行的方式 call 参数一 js方法名, 参数二 js方法参数
若js 方法有多个参数 直接在call 方法后递加即可
若有建议, 欢迎留言

原创粉丝点击