多线程和多进程是什么自行google补脑 对于python 多线程的理解,我花了很长时间,搜索的大部份文章都不够通俗易懂.所以,这里力图用简单的例子,让你对多线程有个初步的认识. 单线程 在好些年前的MS-DOS时代,操作系统处理问题都是单任务的,我想做听音乐和看电影两件事儿,那么一定要先排一下顺序. (好吧!我们不纠结在DOS时代是否有听音乐和看影的应用.^_^) from time import ctime,sleep def music(): for i in range(2): prin…
Python中的描述符是一个相对底层的概念 descriptor Any object which defines the methods get(), set(), or delete(). When a class attribute is a descriptor, its special binding behavior is triggered upon attribute lookup. Normally, using a.b to get, set or delete an att…
Why we need the decorator in python ? Let's see a example: #!/usr/bin/python def fun_1(x): return x*2 def fun_2(x): return x*x*2 if __name__ == '__main__': print 'call fun_1' print fun_1(8) print 'call fun_2' print fun_2(9) We can see more than code…