2018年5月30日

线程锁

摘要: import threading,timenum = 1lock = threading.Lock() #申请一把锁def run(): time.sleep(1) global num lock.acquire() #加锁 num+=1 lock.release() #解锁ts = []for i 阅读全文

posted @ 2018-05-30 17:01 公子兔 阅读(84) 评论(0) 推荐(0) 编辑

多线程、进程

摘要: import threading,timedef run(): time.sleep(3) #干活需要3s print('哈哈哈')# for i in range(5): #串行# run()# for i in range(5):# t = threading.Thread(target=run 阅读全文

posted @ 2018-05-30 17:01 公子兔 阅读(136) 评论(0) 推荐(0) 编辑

重写父类方法

摘要: # coding=utf-8class Zll(): # def smile(self): # print('哈哈哈') # return 'aa' passclass Dcg(): def smile(self): print('啊啊啊啊啊')class Lw(): def smile(self) 阅读全文

posted @ 2018-05-30 16:59 公子兔 阅读(196) 评论(0) 推荐(0) 编辑

封装写日志的类

摘要: import loggingfrom logging import handlersclass MyLogger(): def __init__(self,file_name,level='info',backCount=5,when='D'): logger = logging.getLogger 阅读全文

posted @ 2018-05-30 16:59 公子兔 阅读(121) 评论(0) 推荐(0) 编辑

导航