Discord.py - SyntaxError f-string: 不允许空表达式
Discord.py - SyntaxError f-string: empty expression not allowed
我遇到语法错误:f-string: empty expression not allowed
我不确定(完全)这是什么意思
我试过移动代码并在线查看,但我没有得到不同的结果
密码是:
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
await ctx.send(f"Loaded the {} module!".format(extension))
这是给齿轮的,我确定其他一切都正确,但我不确定
如果有人知道该怎么做,请告诉我,thx
问题是 f-string 中的空 {}。 F-strings 大括号之间需要一个变量名。
带有字符串的行应该是:
await ctx.send(f"Loaded the {extension} module!")
或
await ctx.send("Loaded the {} module!".format(extension))
希望对您有所帮助。
如果你想保持你的代码结构不变,你也可以这样做:
await ctx.send(f"Loaded the {{}} module!".format(extension))
我遇到语法错误:f-string: empty expression not allowed
我不确定(完全)这是什么意思
我试过移动代码并在线查看,但我没有得到不同的结果
密码是:
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
await ctx.send(f"Loaded the {} module!".format(extension))
这是给齿轮的,我确定其他一切都正确,但我不确定
如果有人知道该怎么做,请告诉我,thx
问题是 f-string 中的空 {}。 F-strings 大括号之间需要一个变量名。 带有字符串的行应该是:
await ctx.send(f"Loaded the {extension} module!")
或
await ctx.send("Loaded the {} module!".format(extension))
希望对您有所帮助。
如果你想保持你的代码结构不变,你也可以这样做:
await ctx.send(f"Loaded the {{}} module!".format(extension))