async def answer_question(QUERY, answer):
async with aiohttp.ClientSession() as session:
response = await session.post('http://127.0.0.1:5009/answer', json={
"question": QUERY,
"passage": answer
})
return response.text.replace("\"","")
[TypeError("'coroutine' object is not iterable"), TypeError('vars() argument must have dict attribute')] 通常发生在开发人员使用异步函数时犯了错误。
解决方案:只需添加“await”即可尝试。
应确保仅包含数据库进程、会话管理、请求发送等的async功能默认需要“await”。