Python 3.4.3 asyncio关键字语法错误

Python 3.4.3 asyncio keywords SyntaxError

终端输出值一千字,我猜

[~] $ 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

在 Python 3.5 中添加了 async 关键字。

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)