python如何实现流式接收数据
【代码】python如何实现流式接收数据。
·
import aiohttp
import asyncio
async def stream_response():
async with aiohttp.ClientSession() as session:
async with session.post('your url',headers={"xxx": "xxx"},data='{"xxx": "xxx"}') as response:
async for line in response.content.iter_any():
print(line.decode(),end='')
async def main():
await stream_response()
asyncio.run(main())
更多推荐
已为社区贡献7条内容
所有评论(0)