asyncio AttributeError:''u WindowsSelectorEventLoop'对象没有属性“create\u future”

2024-04-29 08:15:25 发布

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

我尝试使用python3(确切地说是3.6.0a1)学习异步调用。在

我访问了十几个不同的教程网站,加上aiohttp和asyncio文档,一直遇到同样的错误。我已经花了几个小时在google上搜索了这个错误,还尝试了几个小时来查找这个错误。在

https://www.blog.pythonlibrary.org/2016/11/09/an-intro-to-aiohttp/https://aiohttp.readthedocs.io/en/stable/client_quickstart.html#make-a-requesthttps://medium.freecodecamp.org/a-guide-to-asynchronous-programming-in-python-with-asyncio-232e2afa44f6

下面是代码,只是我从很多地方提取的样本:

import aiohttp
import asyncio


async def do_stuff():
    async with aiohttp.ClientSession() as session:
        async with session.get('https://api.github.com/events') as resp:
            print(resp.status)
            print(await resp.text())

loop = asyncio.get_event_loop()
loop.run_until_complete(do_stuff())
loop.close()

错误如下:

“文件”

^{pr2}$

我一辈子都搞不清自己做错了什么。我已经尝试了几十个教程的例子,它们总是导致相同的AttribteError。在

有人能给我指一下正确的方向吗?在


Tags: tohttpsorgimportloopasyncioasyncaiohttp