1、

内嵌函数的内层函数的作用域在外层函数之内,不能在外层函数外调用内层函数。



>>> def a():              ## 外层函数a(),内层函数b().
print("hello world!")
def b():
print("good morning!")
return b()

>>> a()
hello world!
good morning!
>>> b()
Traceback (most recent call last):
File "<pyshell#336>", line 1, in <module>
b()
NameError: name 'b' is not defined