摘要: 1 import contextlib 2 from queue import Queue 3 4 @contextlib.contextmanager 5 def myOpen(file): 6 f = open(file) 7 try: 8 yield f #返回f到with...as..语句中的f 9 finally: 10 ... 阅读全文
posted @ 2017-06-18 19:27 许小伍 阅读(229) 评论(0) 推荐(0) 编辑
摘要: 1 from multiprocessing import Pool 2 from time import sleep 3 def Foo(i): 4 sleep(1) 5 print(i) 6 7 8 if __name__ == "__main__": 9 #5个线程会同时执行 10 pool = Pool(5) 11 12 f... 阅读全文
posted @ 2017-06-18 13:01 许小伍 阅读(592) 评论(0) 推荐(0) 编辑