python - 我正在制作一个使用 8ball 的机器人,所以它说 'random' 不是 var 但我还能做什么,随机答案?

标签 python python-3.x discord.py

@client.command(aliases=['8ball', 'test'])
async def _8ball(ctx, *, question):
    responses =['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 decidedly so.',
                'Most likely.',
                'My reply is no.',
                'My sources say no.',
                'Outlook not so good.',
                'Outlook good.',
                'Reply hazy, try again.',
                'Signs point to yes.',
                'Very doubtful.',
                'Without a doubt.',
                'Yes.',
                'Yes – definitely.',
                'You may rely on it.']
    await ctx.send(f'Question: {question}\nAnswer: {random.choice(responses)}')

最佳答案

试试这个:

import random
@client.command(aliases=['8ball', 'test'])
async def _8ball(ctx, *, question):
    responses =['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 decidedly so.',
                'Most likely.',
                'My reply is no.',
                'My sources say no.',
                'Outlook not so good.',
                'Outlook good.',
                'Reply hazy, try again.',
                'Signs point to yes.',
                'Very doubtful.',
                'Without a doubt.',
                'Yes.',
                'Yes – definitely.',
                'You may rely on it.']
    responce = random.choice(responses)
    await ctx.send(f'Question: {question}\nAnswer: {responce}')

关于python - 我正在制作一个使用 8ball 的机器人,所以它说 'random' 不是 var 但我还能做什么,随机答案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58030116/

相关文章:

python - 我制作了一个获取股票价格的 python 机器人,但我该怎么做才能使参数不使用空格?

java - 如何在 shellbolt 中调用元组上的脚本

python - 列表值的字典理解

python - StreamPlayer "after"函数未被调用

python - 我的代码在读取此 csv 文件并将第一列命名为 "team"时遇到问题

json - 如何从python3中的json文件中检索所有 "name"和 "id"

python - 如何向具有不同设置的用户发送不同的消息?不和谐.py

python - mss sct.grab 不让我选择要使用的显示器

Python: webbrowser.open ("") 打开文件资源管理器窗口

python - celery send_task() 方法