【发布时间】:2021-10-05 12:07:22
【问题描述】:
我是transcrypt 的新手。我创建了一个测试python文件,test.py
def test_def(a: list):
for i in range(len(a)):
print(i)
xx = [2, 3, 4]
test_def(xx)
我有 python 3.9。如果我运行 python 文件,它会按预期运行和打印。
运行 transcrypt 会出现以下错误
> python -m transcrypt -b -m -n .\test.py
Error while compiling (offending file last):
File 'test', line 2, namely:
Error while compiling (offending file last):
File 'test', line 2, namely:
Aborted
我不确定它期望什么以及为什么它会给出错误,任何帮助将不胜感激。
【问题讨论】:
-
我的猜测(这只是一个猜测)是
transcrypt还不支持类型提示。删除: list字符串,我敢打赌它会起作用。 -
@tim-roberts 不,我尝试了两种方式!同样的错误:(
-
你说得对,文档特别声明他们支持这一点。我的错。
-
这是一种预感,因为它在某些编辑器中是不可见的,但是您的文件是否可以将字节顺序标记作为其前几个字符? en.wikipedia.org/wiki/Byte_order_mark
-
如果您将该行更改为等效的
for i,j in enumerate(a):,它将编译。它不能正确翻译文字列表 (xx = [2, 3, 4]),但其余部分看起来还可以。
标签: python transcrypt