反射

#!/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()

 

posted @ 2016-03-07 09:55  fengjian1585  阅读(126)  评论(0编辑  收藏  举报