list - 换行符不适用于嵌入消息中的列表 - Discord.py

标签 list newline discord.py

我有一个以换行符为变量的列表,名为 result

['**Status: **Enabled\n**Q: **What is 2 + 2?\n **\\ A: **4\n\n**Author: **UltimateDucc#9121\n\n\n', '**Status: **Enabled\n**Q: **Where is Ethiopia?\n **\\ A: **Africa\n\n**Author: **BigSnacc#2466\n\n\n']

当我通过不和谐将其作为嵌入式消息发送时:
            l_msg = discord.Embed(
            title =  f'Page {list_msg}',
            description = str(result), 
            colour = discord.Colour.blue()
            )            
            await message.channel.send(embed = l_msg)

每个 \n 都是这样的无论出于何种原因被忽略。

embeddedmessage

任何帮助表示赞赏。

最佳答案

您需要将单个列表条目转换为字符串,而不仅仅是整个列表的字符串表示。这是通过 str.join() 完成的.

尝试将描述行更改为:

description=''.join(result),

结果:

enter image description here

关于list - 换行符不适用于嵌入消息中的列表 - Discord.py,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61569212/

相关文章:

node.js - 从nodejs中的stdin读取强制将\r\n转换为\n

python-3.x - 如何让我的 discord.py 机器人在语音 channel 中播放 mp3?

python - Discord.py - 我应该如何使用 on_reaction_add?

c# - 生成 CSV 文件时,我应该使用什么回车符?

git - 尽管出现 "No newline at end of file"警告,如何在 git gui 中逐行暂存

python - Discord 金钱机器人将用户 ID 保存在 json 文件中。当 Not 重新启动时,它会为每个人创建一个新的(但相同的)ID

python - 对于第三个列表中给定数量的元素,返回两个列表之间的字符串匹配

list - 如何计算行数?

c# - 按日期对数组项进行分组

python - 将 Python 字符串格式化与列表一起使用