[英]Discord.py - SyntaxError f-string: empty expression not allowed
I'm getting a SyntaxError: f-string: empty expression not allowed
I'm not sure (at all) what this means我收到 SyntaxError:
f-string: empty expression not allowed
我不确定(完全)这意味着什么
I've tried moving around the code & looked online but I've got no different results我试过在代码周围移动并在网上查看但我没有得到不同的结果
The code is:代码是:
@client.command()
async def load(ctx, extension):
client.load_extension(f'cogs.{extension}')
await ctx.send(f"Loaded the {} module!".format(extension))
It's for cogs & I'm sure I've got everything else right, I'm not sure though它是用于齿轮的,我确定我已经把其他一切都做对了,但我不确定
If anyone knows what to do then please tell me, thx如果有人知道该怎么做,请告诉我,谢谢
The problem is the empty {} in the f-string.问题在于 f 字符串中的空 {}。 F-strings require a variable name between the braces.
F 字符串需要在大括号之间有一个变量名。 The line with the string should be:
带有字符串的行应该是:
await ctx.send(f"Loaded the {extension} module!")
Or或者
await ctx.send("Loaded the {} module!".format(extension))
Hope this helps.希望这可以帮助。
如果你想保持你的代码结构,你也可以这样做:
await ctx.send(f"Loaded the {{}} module!".format(extension))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.