函数-嵌套函数

#嵌套函数

def func1():

  print(‘alex’)

  def func2():

    print(‘eric’)

#1. func()

func1()

执行结果:

alex

#2 .func()

def func1():

  print(‘alex’)

  def func2():

    print(‘eric’)

  func2()

#1. func()

func1()

执行结果:

alex

eric

1.函数内部可以再次定义函数

2. 执行需要被调用

函数变量取值是有内至外一层层往上找!

 

posted on 2019-05-19 23:10  kingforn  阅读(184)  评论(0编辑  收藏  举报