Discuss / Python / 利用生成器表示全体自然数,然后每调用一次进行next()

利用生成器表示全体自然数,然后每调用一次进行next()

Topic source

虫二YCY

#1 Created at ... [Delete] [Delete and Lock User]

def createCounter(): def count(): i=0 while True: i=i+1 yield i l=count() def counter(): return next(l) return counter


  • 1

Reply