【问题标题】:An example of compiling a python function to javascript将python函数编译为javascript的示例
【发布时间】:2019-08-23 05:58:36
【问题描述】:

假设我有以下功能:

def hello():
    print "hello"

如何使用transcript 之类的程序将其转换为有效的 javascript?

【问题讨论】:

    标签: javascript python


    【解决方案1】:

    您可以按照文档here 使用以下内容运行它:

    transcrypt -b hello.py
    

    但是,这给了我一个非常奇怪的输出:

    export var hello=function(){print("hello")};hello();
    

    我希望它会给出类似的东西:

    console.log('hello')
    

    但这反而打开了打印对话框?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    • 1970-01-01
    相关资源
    最近更新 更多