因此,我正在为Discord进行机器人的工作,并且每次调用函数时都需要一个新的随机生成数字。我该怎么办?我尝试了这个,但它行不通,我只是遇到一个错误,说"对象没有属性'randint'
@bot.command()
async def test(*, message: str=None):
if message is None:
r = random.randint(0, 6779)
await bot.say(r)
尝试使用
random.choice(range(0,6779))
而不是
random.randint(0, 6779)
我认为问题是您写的
random.randint(0, 6779)
你应该写
random.choice(range(0,6779))
而不是