[英]How to fix syntax error on the 'e' of 'else:' in python - discord.py
我不知道為什么會這樣,我檢查了一切,一切似乎都正常。 這是代碼(錯誤大約一半,我在括號旁邊放了一些箭頭。我不確定這是縮進問題還是什么。在此之前,“with open(”上方有一個錯誤) mainbank.json', 'w') as f" 位。
@client.command(name='fight_01')
@commands.cooldown(1, 30, commands.BucketType.user)
async def fight_goblin(ctx):
rng1 = random.randint(1,3)
rng2 = random.randint(1,3)
if rng1 == int('2'):
await ctx.channel.send("You searched all around and couldn't find a goblin, try again next time :(")
else:
await ctx.channel.send('You encountered a wild goblin!')
goblin_hp = int('5')
time.sleep(1.5)
rng3 = random.randint(1, 10)
if rng3 == int('3') or int('4') or int('7'):
user = ctx.author
users = await get_bank_data()
await ctx.channel.send('The goblin got the first hit and you lost 1hp')
users[str(user.id)]['hp'] -= int('1')
dmg = users[str(user.id)]['max_damage']
rng4 = random.randint(0, dmg)
rng5 = str(rng4)
content1 = 'You did ' + rng5 + ' damage'
goblin_hp2 = goblin_hp - int(rng5)
with open("mainbank.json",'w') as f:
json.dump(users,f)
users = await get_bank_data()
if users[str(user.id)]['hp'] <= 0:
await ctx.channel.send('You died, better luck next time')
await ctx.channel.send(content1)
if goblin_hp2 < int('1'):
await ctx.channel.send('You killed the goblin')
users[str(user.id)['bank'] + random.randint(20, 100)
(HERE IS THE PROBELM >>>>>)else:
content2 = 'The goblin now has ' + str(goblin_hp2) + ' health left'
await ctx.channel.send(content2)
rng3 = random.randint(1, 10)
if rng3 == int('3') or int('4') or int('7'):
user = ctx.author
users = await get_bank_data()
await ctx.channel.send('The goblin hit you so you lost 1hp')
users[str(user.id)]['hp'] -= int('1')
dmg = users[str(user.id)]['max_damage']
rng4 = random.randint(0, dmg)
rng5 = str(rng4)
content1 = 'You did ' + rng5 + ' damage'
goblin_hp2 = goblin_hp - int(rng5)
with open("mainbank.json",'w') as f:
json.dump(users,f)
users = await get_bank_data()
if users[str(user.id)]['hp'] <= 0:
await ctx.channel.send('You died, better luck next time')
if goblin_hp2 < int('1'):
await ctx.channel.send('You killed the goblin')
users[str(user.id)['bank'] += random.randint(20, 100)
with open("mainbank.json",'w') as f:
json.dump(users,f)
你的問題是前行
users[str(user.id)['bank'] + random.randint(20, 100)
缺少一個結束]
users[str(user.id)]['bank'] + random.randint(20, 100)
^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.