def f(*args):
if len(args)==1:
start,end,step=0,args[0],1
elif len(args)==2:
start,end,step=args[0],args[1],1
elif len(args)==3:
start,end,step=args[0],args[1],args[2]
else:
raise Exception
if step>0:
while start<end:
yield start
start+=step
raise StopIteration
elif step<0:
while start>end:
yield start
start+=step
raise StopIteration
else:
raise("step can't be zero")

被折叠的 条评论
为什么被折叠?



