动态调用python类和函数
类
class test1(object):
    def __init__(self):
        print "i am test1"
class test2(object):
    def __init__(self):
        print "i am test2"
#  method 1
class_name = 'test1'
eval(class_name)()
# method 2
def exec_class(name):
    name()
exec_class(test2)
 
函数
def show():
    print 'I am show'
def talk():
    print 'I am talk'
method = 'show'
eval(method)()
 
 
 
                    
                 
                
            
         
         
 浙公网安备 33010602011771号
浙公网安备 33010602011771号