aiohttp

作者: long | 2025-03-16

aiohttp是一个专注于异步请求的库,适合高性能的异步 Web 请求。

安装:

pip install aiohttp

示例:

import aiohttp
import asyncio

async def fetch_data():
    async with aiohttp.ClientSession() as session:
        async with session.get('https://api.example.com/data') as response:
            print(await response.json())

asyncio.run(fetch_data())