摘要: #单例模式 #装饰器版本 def singleton(cls): instances = {} def getinstance(): if cls not in instances: instances[cls] = cls() return instances[cls] return getinstance @s... 阅读全文
posted @ 2018-04-07 22:26 Bob__Zhang 阅读(328) 评论(0) 推荐(0) 编辑
摘要: # b = filter(lambda x:x>5,[1,2,3,4,5,6,7]) # print(list(b)) def filters(x): if x > 5: return x b = filter(filters,[1,2,3,4,5,6,7]) print(list(b))#[6, 7] def maps(x): if x > 5: ... 阅读全文
posted @ 2018-04-07 22:04 Bob__Zhang 阅读(178) 评论(0) 推荐(0) 编辑
摘要: #插入排序算法 def insert_sort(lst): for i in range(1,len(lst)): #开始时片段[0:1]已排序 # print(i) x = lst[i] j = i while j > 0 and lst[j-1] > x: lst[j] = lst[j-1] #反... 阅读全文
posted @ 2018-04-07 14:11 Bob__Zhang 阅读(815) 评论(0) 推荐(0) 编辑