python - 我如何将换行符放入列表中?
问题描述
我想在列表中换行
对此
这是代码
@commands.command() #PLAYERS INFO
async def players(self,ctx,ADD,NUM):
with SampClient(address=ADD, port=NUM) as client:
players = [client.name for client in client.get_server_clients()]
lst = [f'{players}']
joined = '\n'.join(lst)
await ctx.send(f'```{joined}```')
解决方案
只需以换行符作为分隔符加入列表
lst = ['list of names']
joined = '\n'.join(lst) # send this
推荐阅读
- python - Python:从列表中删除项目并保持原始列表顺序
- excel - VB脚本按行循环Excel数据
- iframe - Apex 在 IFrame 中添加的额外样式属性
- python - 如果在 Pandas DataFrame 中找到单词,则样式化单元格?
- python - 如何创建可索引的 map() 或修饰的 list()?
- angular - 角度 4-如何在 POST 中将文件发送到后端
- mongodb - 了解 MongoDB 块拆分
- c# - 从没有标头的资源中提取特定数据
- algorithm - Cracking the Coding Interview 中的算法似乎做错了什么
- python - Scrapy CrawlSpider 未加入