首页 > 解决方案 > 机器人发送回复时出现的括号(不和谐,python)

问题描述

我正在制作一个不和谐的 8ball 机器人——出于无聊,但这不是重点。每当我让它发送回复时,括号就会出现在答案应该很简单的地方,有人知道如何解决吗?

这是我的代码

@bot.command(name='8ball', help='Gives the answer to any of your questions')
async def quotelist(ctx):
    quotelist = [
        'As I see it, yes.',
        'Ask again later.',
        'Better not tell you now.',
        'Cannot predict now.',
        'Concentrate and ask again.',
        'Don\'t count on it.',
        'It is certain.',
        'It is decided so.',
    ]
    
    response = random.choices(quotelist)
    await ctx.send(response)

bot.run("Nxxx")```

标签: pythondiscordbots

解决方案


random.choices返回一个选项列表,然后 discord.py 将该列表转换为一个字符串,这是括号的来源。您正在寻找random.choice(注意缺少 s),它只返回列表中的一个元素。


推荐阅读