2019年1月2日
摘要: import pandas as pd def coroutine(func): """装饰器:向前执行到第一个`yield`表达式,预激`func`""" @wraps(func) def primer(*args,**kwargs): gen = func(*args,**kwargs) next(gen) return gen primer.__name__ = fu... 阅读全文
posted @ 2019-01-02 17:27 hailuo 阅读(638) 评论(0) 推荐(0) 编辑
摘要: from collections import Iterable def flatten(items): for x in items: if isinstance(x, Iterable) and not isinstance(x, (str, bytes)): yield from flatte 阅读全文
posted @ 2019-01-02 16:47 hailuo 阅读(1091) 评论(0) 推荐(0) 编辑
摘要: #计数版 class countdown(object): def __init__(self,start): self.start = start def __iter__(self): return countdown_iter(self.start) class countdown_iter(object): def __init__(self, count): sel... 阅读全文
posted @ 2019-01-02 11:32 hailuo 阅读(423) 评论(0) 推荐(0) 编辑