Python--闭包测试

def Funx(x):
    def Funy(y):
        return x*y
    return Funy
print(Funx(5)(7))
def Fun1():
    x = 7
    def Fun2():
        nonlocal x
        x *= x
        return x
    return Fun2()
print(Fun1())

 

posted @ 2018-12-02 17:40  爱跑步的乌龟  阅读(192)  评论(0编辑  收藏  举报