【问题标题】:How to use transcrypt in Python如何在 Python 中使用 transcrypt
【发布时间】:2020-06-06 05:28:52
【问题描述】:

我正在尝试使用 Pyhton 3.7.6 和 transcrypt 3.7.16 转换一些简单的示例,例如海龟树示例 (https://github.com/bunkahle/Transcrypt-Examples/tree/master/turtle)。

基本上,我只是将.py 放在一个文件夹中,然后从cmd 转码:

"python -m transcrypt -n turtle_tree.py";

一切似乎都很好,没有显示错误。 之后,我更改了html文件的第20行写入 "_ _ target_ _/turtle_tree.js",因为输出不在_ _ javascript_ _ 文件夹中。

当我打开 html 时,它打开为空白。

谁能弄清楚我做错了什么?如果有人能提供一些关于这个库的文档,我将不胜感激。

【问题讨论】:

    标签: python transcrypt


    【解决方案1】:

    第 20 行应替换为:

    type="module"> import * as turtle_tree from './__target__/turtle_tree.js'; window.turtle_tree = 龟树;

    然后,从文件夹内的 cmd 中,你必须打开一个 http 服务器:

    python -m http.server
    

    最后,您必须在浏览器中输入:

    http://localhost:8000/turtle_tree.html
    

    就像遵循 Transcrypt docs v.v' 一样简单

    2.2。您的第一个 Transcrypt 程序: https://www.transcrypt.org/docs/html/installation_use.html#your-first-transcrypt-program

    【讨论】:

    • 我还有一些问题。为什么 html 不能像以前的版本那样通过双击它来工作?
    猜你喜欢
    • 2020-11-21
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-28
    • 1970-01-01
    • 2019-07-10
    • 2019-02-22
    相关资源
    最近更新 更多