尝试在 discord python 机器人中使用多个 f 字符串不工作

trying to use multiple f strings in discord python bot not working

你好所以我已经尝试解决这个问题几个小时了,只是无法弄清楚出了什么问题,我之前在 discord python 中进行过 api 调用,但这是第一次像这样使用多个变量的时间。

@client.command()
async def random(ctx):
    url = ('https://randomuser.me/api/')

    response = requests.get(url)
    title = response.json()["title"]
    first = response.json()["first"]
    last = response.json()["last"]
    number = response.json()["number"]
    street = response.json()["name"]
    city = response.json()["city"]
    state = response.json()["state"]
    postcode = response.json()["postcode"]
    country = response.json()["country"]
    phone = response.json()["phone"]
    age = response.json()["age"]
    dob = response.json()["date"]
    gender = response.json()["gender"]
    username = response.json()["username"]
    password = response.json()["password"]
    image = response.json()['large']

    embed = discord.Embed(title="Random Generator", description="**Name:** f'{title}, {first} {last}\n**Address:** {number} {street}, {city}, {state}, {postcode}, {country}\n**Phone:** {phone}\n**Age:** {age}, {dob}\n**Gender:** {gender}\n**Alias:** {username}, {password}\n\n**Profile Picture Link:** {large}'", color=18321)
    embed.set_footer(text="Thanks for using the bot")                                                
    embed.set_image(url="value=f'{large}'")
                                                           
    await ctx.send(embed=embed)

请哪位知道哪里不对可以帮忙谢谢

f-strings 不能在其他字符串中使用

而不是做

description="**Name:** f'..."

你应该做的

description=f"**Name:** {title}..."

与你所有的 f-strings 相同

您不能在 "name: f'{title}'" 等其他字符串中使用 f 字符串。试试这个:

description = f"**Name:** {title}..."