Python 3.4.3 asyncio 关键字 SyntaxError

标签 python python-asyncio

终端输出值一千字,我猜

[~] $ python
Python 3.4.3 (default, Jun 22 2016, 16:03:29)
[GCC 4.9.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> async def fun():
  File "<stdin>", line 1
    async def fun():
            ^
SyntaxError: invalid syntax

最佳答案

asyncawait 语法是在 Python 3.5 中引入的。 ( https://docs.python.org/3/reference/compound_stmts.html#coroutines )

在 Python 3.4 中,您需要使用 @asyncio.coroutine 装饰器和 yield from 语法。 ( https://docs.python.org/3.4/library/asyncio-task.html#coroutines )

关于Python 3.4.3 asyncio 关键字 SyntaxError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38270559/

相关文章:

python - 如何在 asyncio 服务器中实现超时?

python - python 线程或多处理是异步调用的核心吗?

python - 确保 aiohttp/asyncio 中递归函数的 future

python - 使用 dryscrape 和 BeautifulSoup 进行网页抓取

python - 时间序列月平均值 - 想要在月中绘制平均值;目前已到最后

python - 依存解析器不工作 - 斯坦福核心 NLP

python - asyncio.wait 顺序有保证吗?

Python 无法获取 html 标签之间的文本

python - Django:自定义用户模型字段未出现在 Django 管理中

python - 可以或如何在 Google Cloud Functions 上使用 Python asyncio?