我在初始化中声明了一个名为self.current_color =(124,124,124)的变量
稍后在函数上将(124,124,124)的元组值更改为(65,76,436),我有一个返回当前颜色的getter(get_cc)
更改后如何获取值,它仅返回(124,124,124),而不返回(65,74,436)?
答案 0 :(得分:0)
没有代码很难说明问题出在哪里,但是您要实现的目标非常简单。看这个小例子:
In [1]: class MyClass:
...: def __init__(self):
...: self.current_color = (124, 124, 124)
...:
...: def change_color(self):
...: self.current_color = (65, 76, 436)
...:
...: def get_cc(self):
...: return self.current_color
...:
In [2]: o = MyClass()
In [3]: o.get_cc()
Out[3]: (124, 124, 124)
In [4]: o.change_color()
In [5]: o.get_cc()
Out[5]: (65, 76, 436)