#自动引用方法
import commons
inp = input("URL:")
m,f = inp.split(‘/‘)
obj = __import__(m)
def main():
if hasattr(obj,f):
func = getattr(obj,f)
func()
else:
print(‘404‘)
main()
下面是commons
def login():
print("login")
def logout():
print("logout")
def home():
print("home")
输出结果:
URL:commons/home
home
时间: 2024-10-12 12:24:05