【问题标题】:How to send all elements of a python list with discord.py如何使用 discord.py 发送 python 列表的所有元素
【发布时间】:2021-06-26 22:28:12
【问题描述】:
list = [35, 17, 18,5, 30, 20]
embed.add_field(name="Tamanho", value="element\n", inline=False)

我希望能够发送列表中的所有元素并发送相同的embed.add_field我该怎么做,我的意思是列表中的元素数量可以变化,也就是说,它是动态的。 如何将所有元素放在此列表中并发送嵌入?

编辑:

我想说我想为列表中的每个元素换行。

【问题讨论】:

    标签: python python-3.x python-2.7 discord.py


    【解决方案1】:

    你可以用\n作为分隔符加入它

    lst = [35, 17, 18,5, 30, 20]
    joined = '\n'.join([str(elem) for elem in lst])  # casting all elements to a string and joining
    
    embed.add_field(name="Tamanho", value=f"element\n{joined}", inline=False)
    

    输出:

    【讨论】:

      猜你喜欢
      • 2021-12-28
      • 2023-01-17
      • 2020-08-31
      • 1970-01-01
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 2021-06-26
      • 1970-01-01
      相关资源
      最近更新 更多