上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: 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 阅读(74) 评论(0) 推荐(0) 编辑
摘要: 转自http://www.nnzhp.cn/archives/135 一、线程&进程 对于操作系统来说,一个任务就是一个进程(Process),比如打开一个浏览器就是启动一个浏览器进程,打开一个记事本就启动了一个记事本进程,打开两个记事本就启动了两个记事本进程,打开一个Word就启动了一个Word进 阅读全文
posted @ 2018-06-01 11:21 彼得潘jd 阅读(171) 评论(0) 推荐(0) 编辑
摘要: # 经典类和新式类的区别:# 1、 pthon2里面,多继承的时候# 经典类是深度优先# 新式类是广度优先# python3里面都是广度优先# 2、python2 经典类里面不能用super# python3里面经典类和新式类没有任何的区别。class A(object): def x(self): 阅读全文
posted @ 2018-06-01 11:16 彼得潘jd 阅读(98) 评论(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 阅读(146) 评论(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 阅读(138) 评论(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 阅读(78) 评论(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 阅读(101) 评论(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 阅读(105) 评论(0) 推荐(0) 编辑
摘要: class Baby(): country='China' #类变量,公共的变量 def __init__(self,name): print('self的内存地址',id(self)) self.name=name # self代表的就是实例化之后的对象 self.money=5000 self. 阅读全文
posted @ 2018-05-25 18:21 彼得潘jd 阅读(149) 评论(0) 推荐(0) 编辑
摘要: from urllib import parseurl='http://www.baidu.com?qurey=python基础教程 @@@'# url_str=parse.quote_plus(url) #url编码print(parse.quote_plus(url))from urllib i 阅读全文
posted @ 2018-05-25 18:19 彼得潘jd 阅读(450) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页