Definition: A function that encapsulates, operations, and operates on other functions
Parameters:
Support for the transfer of other function names
Arbitrary parameter *args **kwargs
# CODING:GBK def Test (m,n): return m+ndef func (func_name,*args,**Kwargs): = func_name (*args,** Kwargs) return ret+1print(func (test,8,9))
Timeout processing function
#CODING:GBKImportTime
Import Osfile_path= R'C:\Users\Martin\Desktop\finish'defcheck_file_exist (file_name):returnos.path.exists (file_name)defHandle_timeout (Func_name, timeout, *args, * *Kwargs): Interval= 1ret=None whileTimeout >0:begin_time=time.time () ret= Func_name (*args, * *Kwargs)ifret: Breaktime.sleep (interval) Timeout-= Time.time ()-Begin_timereturnRetret= Handle_timeout (check_file_exist,15, File_path)Print(ret)
Import= R'C:\Users\Martin\Desktop\finish'def Install (): time.sleep () = Open (File_path,'w') f.close () install ()
Python-Functional programming