首页 > 解决方案 > 我如何将换行符放入列表中?

问题描述

我想在列表中换行在此处输入图像描述

对此

在此处输入图像描述

这是代码

    @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}```')

标签: pythondiscord.py

解决方案


只需以换行符作为分隔符加入列表

lst = ['list of names']
joined = '\n'.join(lst) # send this

推荐阅读