Loading

python入门之函数的嵌套

函数的嵌套调用

在函数内调用函数

def index():
    print('from index')
 
 
def func():
    index()
    print('from func')
 
 
func()
def funcl(x, y):
    if x > y:
        return x
    else:
        return y
 
 
print(funcl(1, 2))
 
 
def func2(x, y, z, a):
    result = funcl(x, y)
    result = funcl(result, z)
    result = funcl(result, a)
    return result
 
 
print(func2(1, 200000, 3, 1000))

函数的嵌套定义

def index():
    def home():
        print('from home')
    home()
 
 
index()
posted @ 2019-11-11 20:58  开花的马铃薯  阅读(299)  评论(0编辑  收藏  举报