在使用Python中的asyncio时,如何确定read()的最佳参数?是12个字节?还是100个字节?
async with self._session.get(url, headers=headers) as response:
chunk_size = 12
result = ''
while True:
chunk = await response.content.read(chunk_size)
if not chunk:
break
elif isinstance(chunk, (bytes, bytearray)):
data = chunk.decode('utf8')
result += data
readline()
提供)。 - user4815162342