创建生成器

G = (x*2 for x in range(4))
print(G)
print(G.__next__())
print(next(G))#两种方法等价
# G每一次读取,指针都会下移
for x in G:
    print(x,end = " ")

2020-05-08

posted @ 2020-05-08 00:42  CodeYaSuo  阅读(107)  评论(0编辑  收藏  举报