《Python 网络与进阶》练习:aiohttp

《Python 网络与进阶》练习:aiohttp

基于 asyncio 的 HTTP 客户端/服务端框架 aiohttp。

1. 文档与源码

  • 官方文档:https://docs.aiohttp.org/en/stable/
  • 源码:https://github.com/aio-libs/aiohttp

2. 一个最小的异步 GET 请求

import asyncio import aiohttp async def main(): async with aiohttp.ClientSession() as session: async with session.get('https://example.com') as resp: print(resp.status) print(await resp.text()) asyncio.run(main())
阅读 — · 全站 —
🎸 我的歌单 0 首