本文摘自php中文网,作者零下一度,侵删。
错误写法1 2 3 4 5 6 7 8 9 10 11 |
|
按照一般的方法return会报错
需要使用 raise gen.Return(response.body) 代替return
官方例子
1 2 3 4 |
|
In Python 3.3, this exception is no longer necessary: the return
statement can be used directly to return a value (previously yield
and return
with a value could not be combined in the same function).
在python 3.3以上版本, 不在需要抛出异常,可以直接使用return直接返回值。而在之前的版本中,yield和带有返回值的return不能处于一个函数当中。
以上就是Tornado协程在python2.7是怎么使用的?的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
了解Python的collections.counter类型
如何用Python画一只兔子——turtle库circle()画圆函数的详细用法介绍
更多相关阅读请进入《Python》频道 >>

Python编程 从入门到实践 第2版
python入门书籍,非常畅销,超高好评,python官方公认好书。