摘要: 1、 >>> def a(): x = 200 def b(): print("inner:",x) return b() >>> a() inner: 200 2、 >>> def a(): x = 100 def b(): x = 300 print("inner:",x) return b() 阅读全文
posted @ 2021-03-06 16:55 小鲨鱼2018 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 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()( 阅读全文
posted @ 2021-03-06 16:37 小鲨鱼2018 阅读(1115) 评论(0) 推荐(0) 编辑
摘要: 1、 内嵌函数的内层函数的作用域在外层函数之内,不能在外层函数外调用内层函数。 >>> def a(): ## 外层函数a(),内层函数b(). print("hello world!") def b(): print("good morning!") return b() >>> a() hell 阅读全文
posted @ 2021-03-06 16:25 小鲨鱼2018 阅读(605) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> def a(): print("hello world!") >>> a <function a at 0x000002CE49DCB550> >>> a() hello world! 2、 >>> def a(): print("hello world!") def b(): pri 阅读全文
posted @ 2021-03-06 15:57 小鲨鱼2018 阅读(741) 评论(0) 推荐(0) 编辑