1.迭代器:只能往后取值,不能后退 查看一个用.next(2.7),__next__(3.0)
names=['lgs','mike','rain']
names=iter(['lgs','mike','rain'])
print (names.next())
print(names.__next__())
2.生成器
def cash_money(acount):
while acount>0:
acount-=100
yield 100
print("又来取钱了")
atm=cash_money(500)
print(atm.__next__())
print(atm.__next__())
print(atm.__next__())