1. When the function name variable to use
DEF FUNC (): Print ( ' WDC ' ) # A function can be assigned to variables V1 = FUNC V1 () FUNC ()
FUNC DEF ():
Print ( 'WDC')
# function can be placed in the list, the list later performed by bracketed indices
func_list = [FUNC, FUNC, FUNC]
func_list [0] ()
func_list [. 1] ()
func_list [2 ] ()
FUNC DEF ():
Print ( 'WDC')
# function can be placed in the list, performed by the rear brackets for loop
func_list = [FUNC, FUNC, FUNC]
for func_list in Item:
Item ()
FUNC DEF ():
Print ( 'WDC')
# function may also be in the set, but not the same place, or to automatically re-executed only once
func_list FUNC = {, FUNC, FUNC}
for func_list in Item:
Item ()
FUNC DEF ():
Print ( 'WDC')
# automatic repeat function can be placed, the index in parentheses performed
info = { 'K1': FUNC, 'K2': FUNC}
info [ 'K1'] ()
info [ ' K2 '] ()
#### KEY function can be used as a dictionary, but generally do not
2. Functions can be passed as parameters
DEF FUNC (Arg): Print (Arg) DEF show (): return 999 # transfer functions show the address of func (show)
FUNC DEF (Arg):
# parentheses show address equals show (), equivalent to calling the function show
v1 = Arg ()
# not show because the return value, the value of v1 None
Print (v1)
DEF show ():
Print (666)
# pass parameters show the address of
func (show)