Python高级应用与数据分析学习笔记 02
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: fun1
Description :
Author : Lenovo
date: 2018/1/4
-------------------------------------------------
Change Activity:
2018/1/4:
-------------------------------------------------
"""
__author__ = 'Lenovo'
# 基本函数的引用
def fun0():
print("hello world!")
fun0() # hello world!
# 二级函数的嵌套
def fun1():
def fun2():
print("Hello Workd!")
return fun2
# a = fun1()
# a()
fun1()() # hello world!
# 三级函数的嵌套
def fun1():
def fun2():
def fun3():
print("Hello Workd!")
return fun3
return fun2
fun1()()() # hello world!
# 二级函数的闭包
def fun1(x):
def fun2(y):
print(x+y)
return fun2
fun1(3)(10) #13
# 三级函数的闭包
def fun1(x):
def fun2(y):
def fun3(z):
print(x+y+z)
return fun3
return fun2
fun1(3)(10)(5) #18