生成器
用yeild写出range功能
# def func():
# for i in range(10):
# print(i)
# yield i
# g=func()
#
#
# for i in range(10):
# print(g.__next__()+10)
#
# def range(start, end, step=1):
# count = start
# while count < end:
# yield count
# count += step
#
#
# g = range(1, 10, 2)
#
# for i in g:
# print(i)
def range(*args, **kwargs):
start = 1
step = 1
if len(args) == 1:
end = args[0]
elif len(args) == 2:
start = args[0]
end = args[1]
elif len(args) == 3:
start = args[0]
end = args[1]
step = args[2]
else:
raise NameError("asf")
count = start
while count < end:
yield count
count += step
for i in range(1, 10, 2):
print(i)