我想从一个类中调用一个方法,这个方法是由类中的另一个方法创建的。我该怎么做?你知道吗
例如,我刚刚创建了一个名为call me的类,并希望在add
方法中使用subtract
方法的结果。你知道吗
class call_me(object):
def __init__(self, x, y):
self.x = 5
self.y = 10
def subtract(self):
difference = self.y - self.x
return difference
def add(self.subtract,second_number):
# code to add the difference returned by subtract to the second number.
如何在减法返回的差中再加一个数?有没有办法把difference
传给add
?你知道吗
相关问题 更多 >
编程相关推荐