摘要:
range 前面小节已经说明了,range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列。 比如: 1 >>> range(5) 2 [0, 1, 2, 3, 4] 3 >>> range(1,5) 4 [1, 2, 3, 4] 阅读全文
posted @ 2016-08-29 18:43
残宠魔法袋
阅读(786)
评论(0)
推荐(0)
摘要:
Python通过yield提供了对协程的基本支持,但是不完全。而第三方的gevent为Python提供了比较完善的协程支持。 gevent是第三方库,通过greenlet实现协程,其基本思想是: 当一个greenlet遇到IO操作时,比如访问网络,就自动切换到其他的greenlet,等到IO操作完成 阅读全文
posted @ 2016-08-29 16:13
残宠魔法袋
阅读(1560)
评论(0)
推荐(1)
摘要:
monkey patch指的是在运行时动态替换,一般是在startup的时候. 用过gevent就会知道,会在最开头的地方gevent.monkey.patch_all();把标准库中的thread/socket等给替换掉.这样我们在后面使用socket的时候可以跟平常一样使用,无需修改任何代码,但 阅读全文
posted @ 2016-08-29 14:10
残宠魔法袋
阅读(4375)
评论(0)
推荐(0)
摘要:
uswgi学习文档 http://uwsgi-docs-cn.readthedocs.io/zh_CN/latest/WSGIquickstart.html WSGI是什么? WSGI,全称 Web Server Gateway Interface,或者 Python Web Server Gate 阅读全文
posted @ 2016-08-29 13:37
残宠魔法袋
阅读(6238)
评论(0)
推荐(0)
浙公网安备 33010602011771号