Discuss / Python / 返回函数

返回函数

ef createCounter():

 def f():

  x=0

  while True:

   x=x+1

   yield x

 sum=f()

 def counter():

  return next(sum)

 return counter


  • 1

Reply