Jak*_*boi 6 python python-3.x discord.py-rewrite
我收到 SyntaxError: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))
Run Code Online (Sandbox Code Playgroud)
它是用于齿轮的,我确定我已经把其他一切都做对了,但我不确定
如果有人知道该怎么做,请告诉我,谢谢
Cra*_*eak 12
问题在于 f 字符串中的空 {}。F 字符串需要在大括号之间有一个变量名。带有字符串的行应该是:
await ctx.send(f"Loaded the {extension} module!")
Run Code Online (Sandbox Code Playgroud)
或者
await ctx.send("Loaded the {} module!".format(extension))
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
小智 6
如果你想保持你的代码结构,你也可以这样做:
await ctx.send(f"Loaded the {{}} module!".format(extension))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11804 次 |
| 最近记录: |