Klasa Python odzwierciedla metodę instancji członkowskiej

url = input("input url:")  # Enter www.xxx.com/accout/fun to return the result of fun and 404 if it does not exist.
target_module, target_func = url.split('/')
# module = __import__('backend.'+target_module) #Using fromlist=True, you can import backend
module = __import__('backend.'+target_module, fromlist=True) #Using fromlist=True, you can import backend.accout.
func_name = url.split('/')[-1]
if hasattr(module, target_func): #Determine whether module contains target_func members
    target_func = getattr(module, target_func) #Get a reference to func_name
    target_func() #Execution function
peleg tuchman