摘要:
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... 阅读全文
摘要:
from collections import Iterable def flatten(items): for x in items: if isinstance(x, Iterable) and not isinstance(x, (str, bytes)): yield from flatte 阅读全文
摘要:
#计数版 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... 阅读全文