我如何通过Webhook发送python变量

时间:2020-08-25 13:40:11

标签: python discord.py webhooks

我正在尝试通过python中的Discord Webhook发送一个变量,但实际上不是我设置的文本,而是在Webhook上说了变量。这是我将文字设置为:

embed["description"] = "Username: {username}"

这是它要发送的内容
Discord

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:1)

您必须将其设置为f 字符串

username = 'Alex'
embed["description"] = f'Username: {username}'

现在,{username}将替换为Alex