小编330*_*301的帖子

尝试在discord python bot中使用多个f字符串不起作用

您好,所以我已经尝试解决这个问题几个小时了,但无法弄清楚出了什么问题,我之前在 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}, …
Run Code Online (Sandbox Code Playgroud)

python discord f-string discord.py

0
推荐指数
1
解决办法
147
查看次数

标签 统计

discord ×1

discord.py ×1

f-string ×1

python ×1