函数嵌套

函数的嵌套调用:在一个函数内部又调用其他函数

def fun(x,y):
    if x>y:
        return x
    else:
        return y
    
def func(a,b,c,d,e):
    rea=fun(a,b)
    rea1=fun(rea,c)
    rea2=fun(rea1,d)
    rea3=fun(rea2,e)
    return rea3

res=func(1,2,3,4,5)
print(res)

函数的嵌套定义:在函数内又定义了其他函数

def func():
    def foo():
        print('hello')

    print(foo)
    foo()
    x=1
    print(x)

func()

 

posted @ 2018-09-26 21:27  Summerdreamcold  阅读(118)  评论(0编辑  收藏  举报