上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: @要注意定义可变参数和关键字参数的语法:*args是可变参数,args接收的是一个tuple;**kw是关键字参数,kw接收的是一个dict。以及调用函数时如何传入可变参数和关键字参数的语法:可变参数既可以直接传入:func(1, 2, 3),又可以先组装list或tuple,再通过*args传入:... 阅读全文
posted @ 2015-07-07 11:41 何似王 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 1 #-*- coding:utf-8 -*- 2 from multiprocessing import Process,Queue 3 import os,time,random 4 def write(q): 5 for value in ['A','B','C']: 6 ... 阅读全文
posted @ 2015-07-07 10:15 何似王 阅读(421) 评论(0) 推荐(0) 编辑
摘要: 1 #-*- coding:utf-8 -*- 2 from multiprocessing import Pool 3 import os,time,random 4 5 def long_time_task(name): 6 print 'Run task name %s and p... 阅读全文
posted @ 2015-07-07 09:56 何似王 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 1 __author__ = 'liunnis' 2 #-*-coding:utf-8 -*- 3 a=[1,2,3,4,4] 4 print a 5 print list(set(a)) 6 b=[str(i) for i in a] 7 print list(set(b)) 8 #the re... 阅读全文
posted @ 2015-07-06 23:52 何似王 阅读(275) 评论(0) 推荐(0) 编辑
摘要: @原网站因为tuple不可变,所以代码更安全。如果可能,能用tuple代替list就尽量用tuple。tuple的陷阱:当你定义一个tuple时,在定义的时候,tuple的元素就必须被确定下来,比如:>>> t = (1, 2)>>> t(1, 2)如果要定义一个空的tuple,可以写成():>>>... 阅读全文
posted @ 2015-07-06 22:48 何似王 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 在面向对象(OOP)的设计模式中,decorator被称为装饰模式。OOP的装饰模式需要通过继承和组合来实现,而Python除了能支持OOP的decorator外,直接从语法层次支持decorator。Python的decorator可以用函数实现,也可以用类实现。decorator可以增强函数的功... 阅读全文
posted @ 2015-07-06 10:11 何似王 阅读(996) 评论(0) 推荐(0) 编辑
摘要: 在面向对象(OOP)的设计模式中,decorator被称为装饰模式。OOP的装饰模式需要通过继承和组合来实现,而Python除了能支持OOP的decorator外,直接从语法层次支持decorator。Python的decorator可以用函数实现,也可以用类实现。decorator可以增强函数的功... 阅读全文
posted @ 2015-07-06 08:54 何似王 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 虚拟机加ubuntu,累 阅读全文
posted @ 2015-07-05 01:37 何似王 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 1 import time 2 import os 3 4 def consumer(): 5 r = '' 6 while True: 7 n = yield r 8 if not n: 9 return10 ... 阅读全文
posted @ 2015-07-03 09:14 何似王 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 其一:Source code: Lib/queue.pyThe queue module implements multi-producer, multi-consumer queues. It is especially useful in threaded programming when in... 阅读全文
posted @ 2015-07-02 09:14 何似王 阅读(1059) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 下一页