我正在制造一个不和谐的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")```
答案 0 :(得分:2)
random.choices
返回一个选项列表,然后discord.py将列表转换为字符串,方括号来自该字符串。您正在寻找random.choice
(请注意缺少s),该列表仅返回列表中的一个元素。