import asyncio def callback(loop, i): print("success time {} {}".format(i, loop.time())) async def get_html(url): print("start get url") await asyncio.sleep(1) print("end get url") # 两种创建的方法 if __name__ == "__main__": loop = asyncio.get_event_loop() # get_future = asyncio.ensure_future(get_html("http://www.imooc.com")) task = loop.create_task(get_html("http://www.imooc.com")) loop.run_until_complete(task) # 接收的是一个future对象