最近,我在python中添加了一些可选的语句名,这一切都很好,直到我找到if语句并为else和elif添加了一个可选名称:
if_stmt = 'if' test ':' suite ('elif' test ':'suite)* ['else' ':' suite] | 'wenn' test ':' suite ('andernfalls' test ':'suite)* ['sonst' ':' suite]
然后编译没有错误,但是当我用wenn和andrenfalls运行测试时,解释器抛出了错误:
^{pr2}$我做的每一个额外的工作都很好。那么为什么我不能加上其他和elif,我该怎么做呢?在
我正在修改python网站上最新的python2.7代码
编辑 我的测试代码是:
x = 1
y = 2
wenn x > y:
print 1
andernfalls x < y:
print 2
sonst:
print 3
我在顶部添加行的文件是python源代码语法目录中的语法文件
else
和elif
在AST生成代码中有一些特殊情况处理:您必须修改^{} 中的
ast_for_if_stmt
以更改该处理方式。在相关问题 更多 >
编程相关推荐