【问题标题】:discord.py error: IndentationError: unindent does not match any outer indentation leveldiscord.py 错误:IndentationError: unindent 不匹配任何外部缩进级别
【发布时间】:2021-08-05 15:57:37
【问题描述】:

Hello World,我刚开始研究一个不和谐的机器人。

我的机器人可以回答和发送 gif,所以我的下一步是嵌入 gif。

回复 说: IndentationError: unindent 不匹配任何外部缩进级别

任何帮助将不胜感激!

这是我的代码:

对不起,如果它非常基本;-;

代码:

@client.command(hug)
async def reyhugs(ctx):
            embed = discord.Embed(
                title=":x: rey hugs @user",
                color=discord.Colour.purple()
            )
            embed.set_image(url="https://cdn.discordapp.com/attachments/821733999637561385/843251675275591720/steamuserimages-a.akamaihd.net.gif")
        await ctx.send(embed=embed)

【问题讨论】:

  • 检查您是否混合了制表符和空格,或者只是空格太少。

标签: python discord discord.py


【解决方案1】:

您的错误信息说明了一切。您的缩进级别不匹配。由于 Python 是一种解释器语言,因此您确实需要注意这一点!

@client.command(hug)
async def reyhugs(ctx):
    embed = discord.Embed(
        title=":x: rey hugs @user",
        color=discord.Colour.purple()
    )
    embed.set_image(url="https://cdn.discordapp.com/attachments/821733999637561385/843251675275591720/steamuserimages-a.akamaihd.net.gif")
    await ctx.send(embed=embed)

【讨论】:

    【解决方案2】:

    试试这个

    而且你写代码的方式是错误的 纠正它,它会工作的

    @client.command()
    async def reyhugs(ctx):
        embed = discord.Embed(title=f":x: rey hugs {ctx.author.mention}", description="_ _",color=discord.Colour.purple())
        embed.set_image(url="https://cdn.discordapp.com/attachments/821733999637561385/843251675275591720/steamuserimages-a.akamaihd.net.gif")
        await ctx.send(embed=embed)
    

    【讨论】:

    • 谢谢我会努力寻找这些小问题^^
    猜你喜欢
    • 1970-01-01
    • 2010-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多