Aiohttp向discord.py中的字符串添加值

2024-05-28 19:53:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将用户的响应添加到URL中。我的代码是

async def dungeondata():
    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
        async with session.get('https://sky.shiiyu.moe/api/v2/dungeons/{}/{}'.format(name, cutename)) as resp:
            return await resp.json()

@bot.command(name='dungeon', aliases=['dungeons'])
async def dungeon(ctx, name, cutename):
    JSONData = await dungeondata(name, cutename)

当用户执行?dungeons时,我尝试将and添加到URL中,使URL变成https://sky.shiiyu.moe/api/v2/dungeons/name/cutename。我该怎么做


Tags: 用户namehttpsurlasyncaiohttpsessiondef
1条回答
网友
1楼 · 发布于 2024-05-28 19:53:30

dungeon函数中添加namecutename作为参数

async def dungeon(name, cutename):
    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False)) as session:
        async with session.get('https://sky.shiiyu.moe/api/v2/dungeons/{}/{}'.format(name, cutename)) as resp:
            return await resp.json()

相关问题 更多 >

    热门问题