1. Can be cited
def foo(): return ('hello world!') a=foo print(a())
2. Can be used as return value
def outer(): def inner(): print(111) return inner y=outer() and() # todo If you change 111 to inner, add a # todo print(y) at the end of the function to print two identical memory addresses # todo so y is equivalent to inner, so y()=inner()
3. Can be used as a parameter
def foo(): print('hello world!') def foo2(b): print(b) b() foo2(foo) # todo foo2 pass in foo and print the address, b is the same as the address of foo and then add a () call, # todo will output hello world!
4. Can be used as a container type element
def foo(): return ('hello world!') l={'foo':foo} y =l[ ' foo ' ]() print (y) # todo y=l['foo'] to get the function named foo, that is to say y=foo, then add parentheses to call