这是一堂课
Class A:
def __init__(self, a, b):
self.a = a
self.b = b
def set_value(self,"attribut_String",value): # passing a attribute in String
if "attribut_String" = "AAAA":
self.cal_function("a",value)
else "attribut_String" = "BBBB":
self.cal_function("b",value)
def cal_function(self,att,value):
self.att = value # process the passing string as attribute object
现在,我尝试得到这样的结果:
input:rlt = A(a = 1, b = 2)
input:rlt.a
output: 1
input:rlt.set_value("a",3)
input:rlt.a
output:4
可能这似乎没有必要,因为我简化了场景。我必须以这种方式编码