1.函数小高级
a = 123
name = "老男孩好"
nums = [11,22,33,4]
data = numsdef func():pass # 100行代码# func = 函数
def func():print(123)v1 = func
func()
v1()def func():print(123)return 666func_list = [func, func, func]
func_list[0]()
func_list[1]()
func_list[2]()for item in func_list:v = item()print(v)def func():return 123info = {'k1': func,'k2': func()
}
print(info)def func():print(123)def bar():print(666)info = {'k1': func, 'k2': bar} # 函数既可以当字典的key 也可以当value 但一般当value
info['k1']()
info['k2']()def func():print(123)func_list1 = [func, func, func] # 函数名当做变量来使用
func_list2 = [func(), func(), func()]
print(func_list1, func_list2)
123
123
123
[<function func at 0x13a2c0860>, <function func at 0x13a2c0860>, <function func at 0x13a2c0860>] [None, None, None]
2.lambda表达式
3.内置函数