![](/img/trans.png)
[英]Basics - How do I output random.sample to newlines for a Discord bot?
[英]How do I remove brackets, quotes and commas from the output of random.sample (discord bot made with python)
這是我的一段代碼
@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)
輸出看起來像這樣點擊圖片
我希望代碼輸出相同的內容,但沒有括號或引號。 我在這里先向您的幫助表示感謝
您可以使用換行符或分隔符加入
embed = discord.Embed(
title="Random Bishops",
description="\n".join(random.sample(bishops, 2))
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.