首页 > 解决方案 > if 语句中的缩进错误 | 不和谐.py

问题描述

    await ctx.send('Enter the channel name you want to be set as default welcome channel: ')   
else:
    await ctx.send('Only server moderators and owner can use this command')

代码给了我错误:IndentationError: expected an indented block

标签: discord.py

解决方案


该错误不是 DiscordError 子类。
这只是一个缩进错误。
这意味着您的代码没有很好地缩进。

例子

>>> if (True):
    print('True')
IndentationError raised

您必须缩进语句块:

>>> if (True):
         print('True')
'True'

没有任何问题。

综上所述

如果您的错误仅仅是因为错误的缩进,请修复它并接受我的回答。

推荐阅读