摘要: 多任务协程 如果我们想执行多次请求应该怎么办呢?我们可以定义一个 task 列表,然后使用 asyncio 的 wait() 方法即可执行。 import asyncio import time async def request(url): print('正在下载',url) #在异步协程中如果出 阅读全文
posted @ 2020-10-13 15:02 cx0737 阅读(110) 评论(0) 推荐(0)
摘要: aiohttp简介 aiohttp可以实现单线程并发IO操作。 环境安装 pip install aiohttp aiohttp使用 发起请求 async def fetch(): async with aiohttp.ClientSession() as session: async with s 阅读全文
posted @ 2020-10-13 15:00 cx0737 阅读(197) 评论(0) 推荐(0)