第四點,要知道,函數的返回值也可以是函數對象(閉包),比如下面這個例子:
def func_closure():
def get_message(message):
print '11111111111111111111111111111'
print('Got a message: {}'.format(message))
return get_message
send_message = func_closure()
print send_message
print type(send_message)
send_message('hello world')
C:\Python27\python.exe "C:/Users/TLCB/PycharmProjects/untitled2/python study/fun1.py"
<function get_message at 0x00502570>
<type 'function'>
11111111111111111111111111111
Got a message: hello world