简体   繁体   中英

How do I remove brackets, quotes and commas from the output of random.sample (discord bot made with python)

Here is a piece of my code

@client.command()
async def b(ctx):
  bishops = [
        'Bishop', 'Atomic Bishop', 'Lite Bishop', 'Crowding Bishop','Phantom Bishop', 'Sweeping Bishop', 'Ghost Bishop', 'Super Bishop','Murderous Bishop', 'Castler Bishop', 'Princess', 'Bouncing Bishop'
  ]
  embed = discord.Embed(title="Random Bishops", description=random.sample(bishops, 2))
  await ctx.send(embed=embed)

And the output looks like this click for image

I want the code to output the same thing, but without the brackets or quotes. Thanks for the help in advance

You can join with Newline or with a seperator

embed = discord.Embed(
    title="Random Bishops", 
    description="\n".join(random.sample(bishops, 2))
    )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM