1、

内嵌函数中,内层函数可以调用外层函数的局部变量

>>> def a():
    x = 8
    def b():
        print(x + 3)
    return b()

>>> a()
11

 

>>> def a():
    x = 10
    def b(y):
        print(x + y)
    return b

>>> a()(38)
48

 

相关文章:

  • 2022-12-23
  • 2021-09-22
  • 2021-11-30
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2021-08-05
猜你喜欢
  • 2021-08-31
  • 2021-07-07
  • 2021-11-30
  • 2021-11-30
  • 2021-06-22
  • 2022-12-23
相关资源
相似解决方案