摘要: # 生成器n = (i for i in range(0,10000))print(n)def gen(max): n = 0 while n <= max: n +=1 yield ng = gen(10000)for i in g: print(i) 阅读全文
posted @ 2018-08-01 16:34 白水煮茶 阅读(102) 评论(0) 推荐(0) 编辑
摘要: # conding : utf-8# 遍历器class BookCollection: def __init__(self): self.data = ['《往事》','《只能》','《回味》'] self.cur = 0 def __iter__(self): return self def __ 阅读全文
posted @ 2018-08-01 16:24 白水煮茶 阅读(479) 评论(0) 推荐(0) 编辑
摘要: # 列表推导式# 集合推导式# map filtera = [1,2,3,4,5,6,7,8]b = [i**2 for i in a if i >=5]print(b)a = {1,2,3,4,5,6,7,8}b = {i**2 for i in a if i >=6}print(b)# 字典c 阅读全文
posted @ 2018-08-01 11:32 白水煮茶 阅读(170) 评论(0) 推荐(0) 编辑
摘要: # coding:utf-8day = 1def get_sunday(): print(777) return "Sunday"def get_monday(): print(111) return "Monday"def get_tuseday(): print(222) return "Tue 阅读全文
posted @ 2018-08-01 11:12 白水煮茶 阅读(1209) 评论(0) 推荐(0) 编辑