等待负责准备(请求)AttributeError:“NoneType”对象没有属性“prepare”

2024-04-24 14:35:00 发布

您现在位置:Python中文网/ 问答频道 /正文

async def index(request):
    async with aiohttp.ClientSession() as client:
        data=await(email_verification(client))


        await client.post('http://127.0.0.1:8000/acc/signup',data=data)



async def email_verification(client):
    async with client.get('http://www.mocky.io/v2/5c18dfb62f00005b00af1241') as resp:

        return await(resp.json())

但是每当我试图访问这个网址时,我就得到了这个错误

^{pr2}$

我甚至不明白问题出在哪里负责准备来自请


Tags: clienthttpdataasyncindexaiohttpemailrequest
1条回答
网友
1楼 · 发布于 2024-04-24 14:35:00

Web处理程序应返回响应对象,而不是无。在

固定代码是:

async def index(request):
    async with aiohttp.ClientSession() as client:
        data=await(email_verification(client))
        await client.post('http://127.0.0.1:8000/acc/signup',data=data)
    return web.Response(text="OK")

async def email_verification(client):
    async with client.get('http://www.mocky.io/v2/5c18dfb62f00005b00af1241') as resp:
        return await(resp.json())

相关问题 更多 >