在Python中将一个方法的输出传递给另一个方法

在Python中将一个方法的输出传递给另一个方法,python,oop,Python,Oop,我不熟悉对象和类的概念;我想知道有没有更好的方法来访问一个方法的输出并将其传递给另一个方法 class cafec_param: def __init__(self,precip,pe,awc,nmonths): self.precip = precip self.pe = pe self.awc = awc self.nmonths = nmonths def AWC(self): if s

我不熟悉对象和类的概念;我想知道有没有更好的方法来访问一个方法的输出并将其传递给另一个方法

class cafec_param:

    def __init__(self,precip,pe,awc,nmonths):

        self.precip = precip
        self.pe = pe
        self.awc = awc
        self.nmonths = nmonths

    def AWC(self):

        if self.awc<254:
            Ss = self.awc
            Su = 0
        else:
            Ss = 254; Su = self.awc-254
        AWC = Ss + Su
        return AWC,Ss,Su

    def test(self):
        p = cafec_param.AWC(self)[0]
        return p
class-cafec\u参数:
定义初始值(自、精确、pe、awc、N个月):
self.precip=precip
self.pe=pe
self.awc=awc
self.nmonths=nmonths
def AWC(自身):

如果self.awc您可以从awc内部调用所述方法:

   def AWC(self):

        if self.awc<254:
            Ss = self.awc
            Su = 0
        else:
            Ss = 254; Su = self.awc-254
        AWC = Ss + Su
        this.your_method(Ss, Su)
        return AWC,Ss,Su
请注意,我使用了您指定的类、方法和变量的名称,以便我的答案更容易理解。然而,您可能应该看看如何使代码更可读、更易于理解和维护


希望我能帮忙!:)

在类中的另一个方法中调用方法的更好方法

class-cafec\u参数:
定义初始值(自、精确、pe、awc、N个月):
self.precip=precip
self.pe=pe
self.awc=awc
self.nmonths=nmonths
def AWC(自身):

如果self.awcLike,您将使用常规函数执行此操作。获取method1的返回值并将其传递到method2。另外,代码是否与问题有关?现在它看起来只是为了更好的测量。嗨,我只是想摆脱cafec_param.AWC(self)[0]每当我需要Ss时!谢谢,我希望我能投得更高,但是没有声誉。我很高兴。如果你愿意,你可以选择我的答案作为这个问题的答案。
cparam = cafec_param(precip,pe,awc,nmonths)
AWCres, Ss, Su = cparam.AWC()
cparam.your_method(Ss, Su)