python :用@asyncio.coroutine装饰器生成的对象是一个生成器对象 但不是协程对象
用async 定义的函数对象不是一个生成器,但是一个协程对象
import asyncio from collections.abc import Coroutine,Generator @asyncio.coroutine def fun(): print('sssss') async def fun1(): #yield 10 print('end') if __name__=='__main__': fun=fun() fun1=fun1() print(type(fun)) print(isinstance(fun, Generator)) print(isinstance(fun,Coroutine)) print(type(fun1)) print(isinstance(fun1, Generator)) print(isinstance(fun1,Coroutine)) ## <class 'generator'> True False <class 'coroutine'> False True
标签:__,协程,python,fun,print,fun1,isinstance From: https://www.cnblogs.com/howhy/p/17879511.html