itorator迭代器
num_list=[1,2,3,4,5]
num_itier=num_list.__iter__()#创建的迭代器对象
while True:
try:
print(num_itier.__next__()) #获取下一元素
except StopIteration:
break
for循环
for i in range(1,5):
print(i)
函数迭代
def my_range(end, start=0, step=1):
if start > end:
print(f"起始值不能大于结束值")
start = start
while start < end:
print(start)
start += step
type(my_range(start=1, end=10, step=3))
标签:end,迭代,start,range,num,print
From: https://www.cnblogs.com/banchengyanyu/p/17899344.html