随笔分类 -  别说对不起

摘要:以下为转载,但是有改动,原作者在一处写错了,将高写成了低,直接差之毫厘,谬之千里。 环境: centos el5 背景: 由于个人比较喜欢用软件的最新版本,在重新安装服务器上的 xdg-open(还有yum等) 时,在https://rpmfind.net/linux/rpm2html/search 阅读全文
posted @ 2018-09-30 01:15 扫驴 阅读(4149) 评论(0) 推荐(0) 编辑
摘要:import queue as Q def PriorityQueue_int(): que = Q.PriorityQueue() que.put(10) que.put(1) que.put(5) while not que.empty(): print (que.get()) PriorityQueue_int() '''最先弹出1... 阅读全文
posted @ 2018-08-19 18:41 扫驴 阅读(10196) 评论(0) 推荐(0) 编辑
摘要:这个方法定义在object中,所以所有的新式类都继承有该方法,所有的新式类的实例在获取属性value的时候都会调用该方法,为了验证这一结论,我们重写一下该方法: 而旧式类则无次方法,对象获取属性值时也不是通过这个方法获取的,而是另一套机智 阅读全文
posted @ 2018-08-17 14:32 扫驴 阅读(261) 评论(0) 推荐(0) 编辑
摘要:python2的比较函数是cmp.cmp调用的是对象的__cmp__方法,字符串,整数,列表等对象都内置该方法。 而给列表排序的函数sorted,也是通过cmp函数确定两个元素的大小关系,然后再利用插入排序的改进版的(与插入排序原理相同,不同的是,插入排序插入时是从已排序部分的最后一个元素进行比较, 阅读全文
posted @ 2018-08-16 11:44 扫驴 阅读(252) 评论(0) 推荐(0) 编辑
摘要:def aa(): print ('hh') yield '1' print ('gg') yield '2' print ('ff') yield '3' c=['ss','aa','dd'] a='kk'.join(c) print (a)#sskkaakkdd ''' d=[1,2,3] a='kk'.join(d) print ... 阅读全文
posted @ 2018-07-23 07:48 扫驴 阅读(325) 评论(0) 推荐(0) 编辑
摘要:from functools import partial def aa(a,b,c): print ('a :',a) print ('b :',b) print ('c :',c) bb=partial(aa,3,7) bb(6) 阅读全文
posted @ 2018-07-23 07:27 扫驴 阅读(382) 评论(0) 推荐(0) 编辑
摘要:iter是将参数对象转化为迭代器的函数,当参数只有一个的时候很好理解,但是,当参数是两个的时候怎么用呢? Python官方文档对于这种形式的解释是:“ If the second argument, sentinel, is given, then object must be a callable 阅读全文
posted @ 2018-07-23 07:15 扫驴 阅读(492) 评论(0) 推荐(0) 编辑
摘要:cond = threading.Condition() # 类似lock.acquire() cond.acquire() # 类似lock.release() cond.release() # 等待指定触发,同时会释放对锁的获取,直到被notify才重新占有琐。 cond.wait() # 发送 阅读全文
posted @ 2018-07-18 17:53 扫驴 阅读(1217) 评论(0) 推荐(0) 编辑
摘要:全局定义了一个“Flag”,如果“Flag”值为 False,那么当程序执行 event.wait 方法时就会阻塞,如果“Flag”值为True,那么执行event.wait 方法时便不再阻塞。 clear:将“Flag”设置为False set:将“Flag”设置为True 用 threading 阅读全文
posted @ 2018-07-18 15:05 扫驴 阅读(188) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示