终端输出值千言万语,我想
[~] $ 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
答案 0 :(得分:4)
Python 3.5中引入了async
和await
语法。 (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)
答案 1 :(得分:1)
在Python 3.5中添加了async
关键字。