class MyClass:
def __init__(self, i):
self.i = i
def get(self):
func_name = 'function' + self.i
self.func_name() # <-- this does NOT work.
def function1(self):
pass # do something
def function2(self):
pass # do something
这给出了错误:TypeError: 'str' object is not callable
我该怎么做呢?
注意:self.func_name
也不起作用