【问题标题】:Using a variable for a masked link; discord.py embed posted through webhook; python使用变量作为掩码链接; discord.py 嵌入通过 webhook 发布; Python
【发布时间】:2019-07-25 07:56:31
【问题描述】:

对于将发布链接的不和谐机器人,其输出的 URL 将被屏蔽

variable = url + "/collection/" + str(field[1]) + "test"
embed.add_field(name=str(field[0]), value=str("![test]!({variable})"))

不知道这是怎么回事

embed.add_field(name=str(field[0]), value=str("![test]!( https://www.google.com)"))

【问题讨论】:

  • 您好,欢迎来到 Stack Overflow。请发布您在使用此代码时遇到的具体问题。
  • value=str("[test]({variable})")) 如何让变量在屏蔽链接中工作
  • 在 Javascript 中是 ([test](${variable})))

标签: python embed discord discord.py


【解决方案1】:
variable = url + "/collection/" + str(field[1]) + "test"
embed.add_field(name=str(field[0]), value="![test]!({})".format(variable))

format{} 替换为给定的字符串。

【讨论】:

    【解决方案2】:

    我认为你的意思是使用 f-strings

    variable = url + "/collection/" + str(field[1]) + "test"
    embed.add_field(name=str(field[0]), value=str(f"![test]!({variable})"))
    

    这是一个 f-string 与格式化的示例

    a=1
    print('{a}') #prints {a}
    print('{}'.format(a)) #prints 1
    print(f'{a}') #also prints 1
    

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 2020-05-31
      • 2021-07-02
      • 2023-03-06
      • 2020-04-11
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多