高阶函数:若函数参数中有函数,则就为高阶函数。
eg:
def mul(a,b,f): return f(a)*f(b) product=mul(-3,-5,abs) print(product)
abs是一个绝对值函数。注:abs()是对函数的调用。
嵌套函数:
def Shaanxi(): print("Shaanxi is like a cock in the world map") def Yulin(): print("Yulin is the north in Shaanxi") Yulin() Shaanxi()
在嵌套里的函数可看做以局部变量,只能在局部调用。