【发布时间】:2019-06-23 11:24:08
【问题描述】:
在 TypeScript 中,你会做类似的事情
async function getString(word: string): Promise<string> {
return word;
}
如何在 Python 中做同样的事情?我尝试了以下方法:
async def get_string(word: str) -> Coroutine[str]:
return word
并得到了这个回溯:
TypeError: Too few parameters for typing.Coroutine; actual 1, expected 3
所以Coroutine 需要 3 种类型。但为什么?在这种情况下它们应该是什么?
这个在the docs里也有说明,不过还是不明白
【问题讨论】:
标签: python types python-asyncio mypy