Python如何通过多个参数进行for循环

时间:2019-03-26 23:29:57

标签: python asynchronous

我目前能够通过以下代码来运行asyncio:

async def request(url):
    async with aiohttp.ClientSession() as session:
        async with session.get(url) as resp:
            return await resp.json()

async def main():
    results = await asyncio.gather(*[request(u) for u in urls])
    return results

我正在尝试对此进行修改以发出这样的帖子请求

async def request_post(url, postdata, postheader):
    async with aiohttp.ClientSession() as session:
        async with session.post(url, data=postdata, headers=postheader) as resp:
            return await resp.json()

async def main_post():
    results = await asyncio.gather(*[request(u) for u in urls])
    return results

如何写第二行,这样才能遍历多个数据和标题?

0 个答案:

没有答案