我正在用discord模块制作一个discord机器人,但我没有使用异步函数的经验
下面是代码中不起作用的部分:
@client.command()
async def bank(ctx):
global bal
if ctx.author.name in users:
bal.append(0)
else:
print("nope")
print(bal)
bal
以前设置为所有函数之外的空列表
它返回一个巨大的错误,但主要是:
AttributeError: 'Command' object has no attribute 'append'
读取错误
AttributeError: 'Command' object has no attribute 'append'
,看起来bal
变量的类型是object
而不是列表您可以通过检查if语句之前的类型来验证这一点,如下所示:
请确保类型为列表,以便
append
工作相关问题 更多 >
编程相关推荐