用法:
class typing.Coroutine(Awaitable[V_co], Generic[T_co, T_contra, V_co])
collections.abc.Coroutine
的通用版本。类型变量的方差和顺序对应于Generator
,例如:from collections.abc import Coroutine c: Coroutine[list[str], str, int] # Some coroutine defined elsewhere x = c.send('hi') # Inferred type of 'x' is list[str] async def bar() -> None: y = await c # Inferred type of 'y' is int
版本 3.5.3 中的新函数。
自 3.9 版后已弃用:
collections.abc.Coroutine
现在支持[]
.看PEP 585和通用别名类型.
相关用法
- Python typing.Concatenate用法及代码示例
- Python typing.ClassVar用法及代码示例
- Python typing.get_type_hints用法及代码示例
- Python typing.Optional用法及代码示例
- Python typing.Final用法及代码示例
- Python typing.TypedDict.__optional_keys__用法及代码示例
- Python typing.Protocol用法及代码示例
- Python typing.NoReturn用法及代码示例
- Python typing.TypedDict.__total__用法及代码示例
- Python typing.is_typeddict用法及代码示例
- Python typing.TypeVar用法及代码示例
- Python typing.AsyncGenerator用法及代码示例
- Python typing.final用法及代码示例
- Python typing.ParamSpec用法及代码示例
- Python typing.Literal用法及代码示例
- Python typing.overload用法及代码示例
- Python typing.TYPE_CHECKING用法及代码示例
- Python typing.TypedDict用法及代码示例
- Python typing.List用法及代码示例
- Python typing.Generic用法及代码示例
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 typing.Coroutine。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。