tornado源码中不支持在self.write()中直接传入list对象,源代码如下 def write(self, chunk): if self._finished: raise RuntimeError("Cannot write() after finish()") if not isinstance(chunk, (bytes, unicode_type, dict)): message = "write() only accepts bytes, unicode
今天去逛论坛 时发现了一个很有趣的问题: 谁能给我我解释一下这段程序的结果为什么是:2.而不是:3 代码如下: class Test { public int aaa() { int x = 1; try { return ++x; } catch (Exception e) { } finally { ++x; } return x; } public static void main(String[] args) { Test t = new Test(); int y = t.aaa();
1.输出 再来看看输出`write`,实际上,`write`并没有直接把数据返回给前端,而是先写到缓存区,函数结束之后才会返回到前端,我们验证如下 class FlushHandler(tornado.web.RequestHandler): def get(self): self.write('this is '+'<br>') self.write('tornado'+'<br>') self.flush() import time time.sleep(5) self.wri