monsters.create()
for monster in World.monsters:
if monster.name == "Valley Wolf":
Game.Log("Found the wolf!")
else:
Game.Log("Could not find the wolf!")上面的代码结果是“找不到狼!”打印,但当我将其更改为以下内容时:
monsters.create()
for monster in World.monsters:
Game.Log(monster.name)它打印“谷狼”……我很困惑为什么这个值看起来是“谷狼”,而if语句返回的是False,运行的是else……
发布于 2020-01-15 12:59:03
这可能是因为额外的字符,所以尝试:
for monster in World.monsters:
if "Valley Wolf" in monster.name:
Game.Log("Found the wolf!")
else:
Game.Log("Could not find the wolf!")https://stackoverflow.com/questions/59745322
复制相似问题