函数 嵌套 串联使用 Python

先看例子:

def get_early_stopping(monitor=5, patience=6):
    return get_model_path(a=monitor, b=patience)

def get_model_checkpoint(model_path = 'Python'):
    return print('Why ' + model_path + ' is so difficult for newbies to learn ?')

def get_model_path(a=1,b=2):
    return a + b

def get_callbacks():
    stopping = get_early_stopping(monitor=7, patience=8)
    model_path = get_model_path(3, 4)
    checkpointer = get_model_checkpoint(model_path = 'Perl')
    return [stopping, model_path, checkpointer]

[x, y, z] = get_callbacks()
print(get_callbacks())
print(y)
d = get_model_path(3,7)
print(d)

assert
Why Perl is so difficult for newbies to learn ?
Why Perl is so difficult for newbies to learn ?
[15, 7, None]
7
10

猜你喜欢

转载自blog.csdn.net/weixin_43414981/article/details/90549312
今日推荐