frange 1>>>import itertools 2>>>def frange(start, end=None, inc=1.0): 3if end is None: 4 end = start +0.0 5 start =0.0 6assert inc 7for i in itertools.count(): 8 next = start + i * inc 9if(inc>0.0and next >= end) or (inc<0.0and next <= end): 10break 11yield next 12
1>>>for j in frange(1.0, 5.0, 0.5): 2print(j)
Outputs:
1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5
posted on
2009-10-29 22:50Ray Z
阅读(176)
评论(0)
编辑收藏举报