我的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 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://docs.python.org/3/tutorial/inputoutput.html#the-string-format-method
相关问题 更多 >
编程相关推荐