Python 如何在一行中使用同一参数两次?
我的discord bot有以下代码:Python 如何在一行中使用同一参数两次?,python,string,join,discord,arguments,Python,String,Join,Discord,Arguments,我的discord bot有以下代码: @bot.command(brief="Za map napiš Rod a druh a vyskočí ti mapa výskytu!") async def map(ctx, *args): if not args: await ctx.channel.send("Nenapsal jsi Rod/ Rod a druh! \nVysvětlivka:") await
@bot.command(brief="Za map napiš Rod a druh a vyskočí ti mapa výskytu!")
async def map(ctx, *args):
if not args:
await ctx.channel.send("Nenapsal jsi Rod/ Rod a druh! \nVysvětlivka:")
await ctx.channel.send(
"https://cdn.discordapp.com/attachments/661985293834125342/808308254081417227/acz_map_command.png"
)
else:
await ctx.channel.send('Mapa výskytu: *{}*'.format(
' '.join(args).capitalize()))
await ctx.channel.send(
'https://antmap.coc.tools/images/{}.png '.format(
'.'.join(args).capitalize()))
await ctx.channel.send('AntWiki: *{}*'.format(
' '.join(args).capitalize()))
await ctx.channel.send(
'https://antwiki.org/wiki/{}'.format(
'_'.join(args).capitalize()))
问题在于:
await ctx.channel.send(
'https://antmap.coc.tools/images/{}.png '.format(
'.'.join(args).capitalize()))
使用命令https:/antmap.coc.tools/images/Argument1.Argument2.png后,Bot会发送此消息
但是现在我需要更改它,所以它发送https:/antmap.coc.tools/images/Argument1/Argument1.Argument2.png
如果是这样的话:
'https://antmap.coc.tools/images/{}/{}.png'
'https://antmap.coc.tools/images/{}.png'.format(
'/','.'.join(args).capitalize()
或者像这样:
'https://antmap.coc.tools/images/{}/{}.png'
'https://antmap.coc.tools/images/{}.png'.format(
'/','.'.join(args).capitalize()
或者类似的
我搜索了一下答案,但还没找到答案。试试:
'https://antmap.coc.tools/images/{}/{}.{}.png'.格式(arg1,arg1,arg2)
请看:它对我不起作用