#生成器的应用
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
转载请注明原文地址:https://tech.qufami.com/read-18994.html