摘要:
#生成器def MyDemo(M): for i in range(M): yield i**2for item in MyDemo(9): print(item)# #生成器import sysa=(i**2 for i in range(5))while True: try: print(nex 阅读全文
摘要:
#迭代器import syslist=[1,2,3,4]it=iter(list)while True: try: print(next(it)) except StopIteration: sys.exit() #迭代器it=iter(list)print(next(it))print(next( 阅读全文