非常恼人的错误[python/p3d]

2024-05-06 13:01:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码中有这一部分,它起源于Panda 1.7.2/Python 2.4:

Factions = tuple(lambda [outmost-iterable]: for x in [outmost-iterable]: AvatarType(faction = x)(range(9)))
(Undead, Navy, Creature, Townfolk, Pirate, TradingCo, Ghost, VoodooZombie, BountyHunter) = Factions

在Python 2.7/Panda 1.8.1中运行代码时,会出现以下错误:

Factions = tuple(lambda x for x in [outmost-iterable]:
                                  ^
SyntaxError: invalid syntax

我已经尝试了所有可能的方法来修复它,但是我仍然无法找到它,它不在文档中,我真的很绝望。有没有办法修复一下,这样就可以兼容2.7了?你知道吗


Tags: lambda代码inforrangeiterablepandatuple