为随机命令添加权重时的括号
Brackets When I Add Weights To Random Command
我尝试为我的随机代码添加权重。我设法增加了权重,但响应中有括号。有人可以帮帮我吗?谢谢!
@bot.command()
async def sus(ctx):
dre = ["Cyan faked trash!",
"Red was following me!",
"White vented right in front of me!",
"Pink is so sus",
"Brown sabotaged the reactor!",
"**ELECTRICAL**",
"Purple is the- oh, he's dead.",
]
await ctx.send(f'{random.choices(dre, weights=(500, 500, 500, 500, 500, 100, 500))}')
random.choices
总是 returns 一个列表。由于该列表将始终包含一个项目,因此您每次都可以只使用第一个元素:
choice = random.choices(dre, weights=(500, 500, 500, 500, 500, 100, 500))[0]
await ctx.send(choice)
我尝试为我的随机代码添加权重。我设法增加了权重,但响应中有括号。有人可以帮帮我吗?谢谢!
@bot.command()
async def sus(ctx):
dre = ["Cyan faked trash!",
"Red was following me!",
"White vented right in front of me!",
"Pink is so sus",
"Brown sabotaged the reactor!",
"**ELECTRICAL**",
"Purple is the- oh, he's dead.",
]
await ctx.send(f'{random.choices(dre, weights=(500, 500, 500, 500, 500, 100, 500))}')
random.choices
总是 returns 一个列表。由于该列表将始终包含一个项目,因此您每次都可以只使用第一个元素:
choice = random.choices(dre, weights=(500, 500, 500, 500, 500, 100, 500))[0]
await ctx.send(choice)