python - 机器人发送回复时出现的括号(不和谐,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")```
解决方案
random.choices
返回一个选项列表,然后 discord.py 将该列表转换为一个字符串,这是括号的来源。您正在寻找random.choice
(注意缺少 s),它只返回列表中的一个元素。
推荐阅读
- android - Android:ListView 适配器能否将其构造函数的上下文用于 Toast?
- javascript - 返回响应头 OnAuthenticationFailed
- sql - Hive 中的窗口函数
- reactjs - 有没有办法使用流来限制特定的字符串模式?
- grafana - Ceph Luminous 的 Collectd 插件问题
- javascript - 如何执行这两个 OnScrolls?
- google-analytics - GA BigQuery 导出 - COUNT(DISTINCT(fullVisitorId)) 与源/媒介多算
- c++ - unordered_map 不应该只有两个参数吗?
- c - c语言中使用fork()处理socket中多个客户端的逻辑问题
- timer - STM32F4上定时器和spi之间的中断优先级问题