生成器

tech2024-11-07  21

#生成器的应用 g=(i for i in range(10)) print(g) print(f' next :{g.__next__()}') print(f' next :{g.__next__()}') for i in g: print(i)

输出:

F:\python3.6\python.exe E:/python_project/图像处理3/生成器.py <generator object <genexpr> at 0x00000274636E7AC8> next :0 next :1 2 3 4 5 6 7 8 9
最新回复(0)