【问题标题】:setting 2 values for a field in a discord embed为不和谐嵌入中的字段设置 2 个值
【发布时间】:2018-10-22 14:44:31
【问题描述】:

所以我需要使用具有 value= 的字段嵌入不和谐,但我需要在同一个字段中显示两个值,我从 API 中提取数据并且我有以下代码:

        itemobtain = item['obtained']['obtained']
        itemobtaintype = item['obtained']['type']

Obtained 获得打印商店中物品的成本,获得类型打印用于该物品的货币,我需要类型显示在成本之后但在同一字段中 例如,如果 itemobtain 是 800,itemobtaintype 是 vbucks,我需要在字段中填写“800 vbucks”

我试过这段代码:

embed.add_field(name="Obtainable from", value='{}'.format(itemobtain), value='{}\n'.format(itemobtaintype), inline=False)

但收到错误“关键字参数重复”,因为我希望您不能有两个值 =。有谁知道如何做到这一点,或者如果可能的话?

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    稍微摆弄一下正确的代码是

    embed.add_field(name="Obtainable from", value='{} {{}}'.format(itemobtain).format(itemobtaintype), inline=True)
    

    【讨论】:

    • 你也可以value='{} {}'.format(itemobtain, itemobtaintype)
    猜你喜欢
    • 2021-12-17
    • 2019-11-05
    • 1970-01-01
    • 2021-08-24
    • 2021-04-14
    • 2020-04-12
    • 2017-03-23
    • 1970-01-01
    • 2021-12-03
    相关资源
    最近更新 更多