gpt4 book ai didi

python - if 语句的语法无效

转载 作者:行者123 更新时间:2023-11-28 19:58:31 24 4
gpt4 key购买 nike

我只是粘贴整个函数,因为它不是那么长:

def decideTile():
global tile
global exp
global maxexp

tile += 1
exp += math.ceil(random.randrange(math.ceil((maxexp/2)/2,maxexp/2))

if exp >= maxexp:
levelUp()
else:
tileChoices = ['Battle','Loot','Nothing']
fileType = random.choice(tileChoices)

if tileType == 'Battle':
battle()
elif tileType == 'Loot':
loot()
elif tileType == 'Nothing':
nothing()

现在,Python 说

if exp >= maxexp:

其中一部分是“无效语法”,我不完全确定原因。感谢您的帮助!

最佳答案

上一行中缺少一个括号。要解决此问题,只需在该行的末尾添加一个右括号,如下所示:

exp += math.ceil(random.randrange(math.ceil((maxexp/2)/2,maxexp/2)))

关于python - if 语句的语法无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8698325/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com