会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
扫驴
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
13
14
15
16
17
18
19
20
21
···
31
下一页
2018年8月16日
python2的比较函数,cmp
摘要: python2的比较函数是cmp.cmp调用的是对象的__cmp__方法,字符串,整数,列表等对象都内置该方法。 而给列表排序的函数sorted,也是通过cmp函数确定两个元素的大小关系,然后再利用插入排序的改进版的(与插入排序原理相同,不同的是,插入排序插入时是从已排序部分的最后一个元素进行比较,
阅读全文
posted @ 2018-08-16 11:44 扫驴
阅读(265)
评论(0)
推荐(0)
2018年8月3日
快速排序
摘要: def bb(a,low,high): if low=end: return start_begi=begi start_end=end begi+=1 while begi=lis[start_begi]: end-=1 lis[begi],lis[end]...
阅读全文
posted @ 2018-08-03 17:25 扫驴
阅读(173)
评论(0)
推荐(0)
2018年7月23日
如果a,b,c为自然数,a+b+c=1000,a方+b方=c方,求出abc可能的组合(python实现)
摘要: 哈哈
阅读全文
posted @ 2018-07-23 18:24 扫驴
阅读(1342)
评论(0)
推荐(0)
python之join
摘要: 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 扫驴
阅读(329)
评论(0)
推荐(0)
python之functools partial
摘要: 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 扫驴
阅读(386)
评论(0)
推荐(0)
Python 3 iter函数用法简述
摘要: iter是将参数对象转化为迭代器的函数,当参数只有一个的时候很好理解,但是,当参数是两个的时候怎么用呢? Python官方文档对于这种形式的解释是:“ If the second argument, sentinel, is given, then object must be a callable
阅读全文
posted @ 2018-07-23 07:15 扫驴
阅读(514)
评论(0)
推荐(0)
2018年7月20日
一个疑问,int对象5为何没有__dict__属性,而类却有,这是怎么做到的?对象不是都可以调用类属性吗?
摘要: a=1 print hasattr(a.__dict__) print hasattr(a.__class__.__dict__)
阅读全文
posted @ 2018-07-20 12:59 扫驴
阅读(379)
评论(0)
推荐(0)
2018年7月18日
python线程之condition
摘要: cond = threading.Condition() # 类似lock.acquire() cond.acquire() # 类似lock.release() cond.release() # 等待指定触发,同时会释放对锁的获取,直到被notify才重新占有琐。 cond.wait() # 发送
阅读全文
posted @ 2018-07-18 17:53 扫驴
阅读(1233)
评论(0)
推荐(0)
python 线程 event
摘要: 全局定义了一个“Flag”,如果“Flag”值为 False,那么当程序执行 event.wait 方法时就会阻塞,如果“Flag”值为True,那么执行event.wait 方法时便不再阻塞。 clear:将“Flag”设置为False set:将“Flag”设置为True 用 threading
阅读全文
posted @ 2018-07-18 15:05 扫驴
阅读(194)
评论(0)
推荐(0)
2018年7月17日
getattr getattribute setattr hasattr delattr
摘要: getattr是返回对象属性value的函数,用法:getattr(object,attribute_name[,default]) 如果对象拥有属性,则返回属性value,如果对象没有该属性并且也没有定义__getattr__方法的时候,则要么抛出异常要么有default参数返回default值。
阅读全文
posted @ 2018-07-17 17:33 扫驴
阅读(296)
评论(0)
推荐(0)
上一页
1
···
13
14
15
16
17
18
19
20
21
···
31
下一页
公告