博特代码错误:预期的缩进块

博特代码错误:预期的缩进块

问题描述:

,所以我现在有这样的代码,这使得一个很可能很可能对我的不和谐机器人,我有这个错误的地方说:“齿痕错误:预期和缩进块”博特代码错误:预期的缩进块

下面是我使用的代码(见https://hastebin.com/isageyoqih.py

import discord 
import asyncio 
import random 
import pickle 
import os 

client = discord.Client() 

@client.event 
async def on_ready(): 
    print('Ready and with') 
    print(client.user.name) 

@client.event 
async def on_message(message): 
    if message.content.startswith('_whatcanyoudo?'): 
     msg = await client.send_message(message.channel, '```Heres what i can do :```') 
     await asyncio.sleep(0.5) 
     msg2 = await client.send_message(message.channel, '```For now, i can only do a thing called "flip a coin"```') 
     await asyncio.sleep(0.5) 
     msg3 = await client.send_message(message.channel, '```Bot powered by Ouindoze™, message will delete in 15 seconds```') 
     await asyncio.sleep(15) 
     await client.delete_message(msg) 
     await client.delete_message(msg2) 
     await client.delete_message(msg3) 


    elif message.content.startswith('_8ball'): 
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later']) 
    msg5 = await client.send_message(message.channel, 8ball) 

client.run('I obiously won't share the token duh xd') 

Here is the error I got

elif message.content.startswith('_8ball'): 
8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later']) 
msg5 = await client.send_message(message.channel, 8ball) 

应该是(elif后注压痕)

elif message.content.startswith('_8ball'): 
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later']) 
    msg5 = await client.send_message(message.channel, 8ball) 

,并顺便说一下,8ball是非法的名字一个变量作为变量名已经开始与下划线符号_)。

注: 长的列表可以在多行以提高可读性分裂:

ball = random.choice([ 
     'It is certain', 
     'As i see it, yes', 
     'Dont count on it', 
     'Without a doubt', 
     'Definitely', 
     'Very doubtful', 
     'Outlook not so good', 
     'My sources say no', 
     'My reply is no', 
     'Most likely', 
     'You may rely on it', 
     'Ask again later' 
     ]) 
+0

这样的问题应该已经被评论和投票结束为一个简单的印刷错误。由于这个问题不会对未来的读者有所帮助,除了OP – abccd

+0

非常感谢,我已经在这个2小时xD – Ouindoze

elif message.content.startswith('_8ball'): 
    8ball = random.choice(['It is certain','As i see it, yes', 'Dont count on it', 'Without a doubt', 'Definitely', 'Very doubtful', 'Outlook not so good', 'My sources say no', 'My reply is no', 'Most likely', 'You may rely on it', 'Ask again later']) 
    msg5 = await client.send_message(message.channel, 8ball) 

那么它到底是什么错误消息说:缩进它。