将python函数编译为javascript的示例

问题描述 投票:-4回答:1

我们假设我有以下功能:

def hello():
    print "hello"

我如何使用像transcript这样的程序将其转换为有效的javascript?

javascript python
1个回答
-1
投票

您可以根据文档here使用以下命令运行它:

transcrypt -b hello.py

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

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

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

console.log('hello')

但这反过来打开了打印对话框?

© www.soinside.com 2019 - 2024. All rights reserved.