上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: import threading,timedef run(): time.sleep(3) print('哈哈哈')for i in range(50): t = threading.Thread(target=run) t.setDaemon(True) #把子线程设置成守护线程 (主线程一死,守 阅读全文
posted @ 2018-06-01 11:26 彼得潘jd 阅读(85) 评论(0) 推荐(0)
摘要: import threading,timedef run(): time.sleep(3) print('哈哈哈')start_time=time.time()threads=[] #存放启动的5个线程for i in range(5): t = threading.Thread(target=ru 阅读全文
posted @ 2018-06-01 11:25 彼得潘jd 阅读(81) 评论(0) 推荐(0)
摘要: import threading,timenum=1lock=threading.Lock() #申请一把锁def run(): time.sleep(1) global num lock.acquire() #加锁 #python3里面不加也无所谓,python2里面要加锁 num+=1 lock 阅读全文
posted @ 2018-06-01 11:25 彼得潘jd 阅读(83) 评论(0) 推荐(0)
摘要: 转自http://www.nnzhp.cn/archives/135 一、线程&进程 对于操作系统来说,一个任务就是一个进程(Process),比如打开一个浏览器就是启动一个浏览器进程,打开一个记事本就启动了一个记事本进程,打开两个记事本就启动了两个记事本进程,打开一个Word就启动了一个Word进 阅读全文
posted @ 2018-06-01 11:21 彼得潘jd 阅读(181) 评论(0) 推荐(0)
摘要: # 经典类和新式类的区别:# 1、 pthon2里面,多继承的时候# 经典类是深度优先# 新式类是广度优先# python3里面都是广度优先# 2、python2 经典类里面不能用super# python3里面经典类和新式类没有任何的区别。class A(object): def x(self): 阅读全文
posted @ 2018-06-01 11:16 彼得潘jd 阅读(103) 评论(0) 推荐(0)
摘要: class Zll(): def smile(self): print('哈哈哈')class Dcg(): def smile(self): print('啊啊啊')class Lw(): def smile(self): print('嘿嘿嘿')class Xz(Zll,Dcg,Lw): #多继 阅读全文
posted @ 2018-06-01 11:15 彼得潘jd 阅读(179) 评论(0) 推荐(0)
摘要: import redisclass MyRedis(): def __init__(self,ip,password,port=6379,db=10): #构造函数 try: self.r=redis.Redis(host=ip,password=password,port=port,db=db) 阅读全文
posted @ 2018-06-01 11:10 彼得潘jd 阅读(143) 评论(0) 推荐(0)
摘要: class Zll(object): def __init__(self): self.money=100000000 self.house='3环里20套' def sing(self): print('唱歌') def dance(self): print('跳广场舞') def lm(self 阅读全文
posted @ 2018-05-25 18:26 彼得潘jd 阅读(84) 评论(0) 推荐(0)
摘要: import redisclass My(object): try: def __init__(self): self.__host='xxx.xxx.xxx.xxx' self.__port=6379 self.__password='123456' self.r=redis.Redis(host 阅读全文
posted @ 2018-05-25 18:24 彼得潘jd 阅读(104) 评论(0) 推荐(0)
摘要: import pymysqlclass MyDb(object): #新式类 def __del__(self):#析构函数 self.cur.close() self.coon.close() print('over...') def __init__(self, #构造函数 host,user, 阅读全文
posted @ 2018-05-25 18:22 彼得潘jd 阅读(112) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页