反射
#!/usr/bin/env python # -*- coding:utf-8 -*- ''' from backend import account account.login() account.logout() import backend.account backend.account.login() ''' data = raw_input('请输入地址: ') array = data.split('/') userspace = __import__('backend.'+array[0]) #<module 'backend' from 'D:\python-test\backend\__init__.pyc'> model = getattr(userspace,array[0]) #<module 'backend.account' from 'D:\python-test\day3\backend\account.pyc'> fun = getattr(model,array[1]) print fun()