Importing modules as strings
In the form of a string, go to the module to look for the established function, and execute getattr (module name, function name, default value)
In the form of a string, the SetAttr (module name, function name/variable name, lambda expression/variable value) is set to the module.
Remove something delattr (module name, function name) from the module in the form of a string
To manipulate members of an object (a module) in the form of a string
1 INP = input ( " Please enter the module name: " ) 2 inp_func = input ( " Enter the function you want to execute: " ) 3 dd = __ import__ (INP) # import modules as strings
# from XXX.XX Import oo is equivalent to __import__ (' xxx.xx.oo ', fromlist = True)
4 # looking for a function in the module as a string if no returned none is found
5 r = Target_func ()
6 Print (r)
# in-Memory operations
Hasattr (module name, function name) # to determine if a function exists
SetAttr (module name, function name/variable name, lambda expression/variable value)
Delattr (module name, function name)
Results:
Please enter the module name: Commons
Please enter the function to execute: F1
F1
The reflection of Python