函數是第一類對象,即函數能夠被當作數據處理。python
def func(): print('from func') print(func)
<function func at 0x10af72f28>
函數
x = 'hello nick' y = x f = func print(f)
<function func at 0x10af72f28>
2.看成參數傳給一個函數code
len(x) def foo(m): m() foo(func)
from func
3.能夠看成函數的返回值對象
def foo(x): return x res = foo(func) print(res) res()
<function func at 0x10af72f28> from func
4.能夠看成容器類型的元素內存
l = [x] function_list = [func] function_list[0]()
from func
io