'''
#占用内存
def createlist():
mylist=[x for x in range(10000)]
return mylist
print(createlist())
'''
#用生成器函数,节约内存
def createlist():
for i in range(100):
print(i)
yield i # next一次,返回一次
X=createlist() #必须用一个变量(X)把迭代器函数装起来,直接next(createlist()) 会始终返回第一个yield的返回值
print(type(X)) #生成器类型(generator)
next(X)
next(X)
next(X)
next(X)