一直在说
await ctx.send("{}:".format(random.choice(a_var1)), "{}:".format(random.choice(a_var1)))
TypeError: send() takes from 1 to 2 positional arguments but 3 were given
@bot.command(pass_context=True)
async def a_message(ctx):
a_var1 = [
"a1",
"a2",]
a_var2 = [
"b1",
"b2",]
await ctx.send("{}:".format(random.choice(a_var1)), "{}:".format(random.choice(a_var2)))
就像,您如何说“ a1:b2”,而不仅仅是“ a1”。如果有人可以帮助我,那将不胜感激!
答案 0 :(得分:0)
您应该连接字符串。您正在将它们作为参数传递。
您可以使用
ctx.send("{}:".format(random.choice(a_var1)) + "{}:".format(random.choice(a_var2)))
答案 1 :(得分:0)
只需将“,”替换为“ +”即可进行连接
ctx.send("{}:".format(random.choice(a_var1)) + "{}:".format(random.choice(a_var2)))
答案 2 :(得分:0)
你想做
await ctx.send("{0}:{1}:".format(random.choice(a_var1), random.choice(a_var2)))
我建议您阅读discord.py Documentation,并可以选择了解有关f-strings的信息