0

TypeError: Find_Number() missing 1 required positional argument: 'limitdivision'
我仍然不明白为什么我的代码是错误的:

def main():
    obj = FindMaxNumber()
    result = obj.Final_Result(500)
    print("The Final Result is {} ". format(result))

class FindMaxNumber():
    delf Find_Division(self, num):  
        self.num = num      
        if num%2==0:
            num = num/2
            count = 0
            division = 1
            while num%2==0:
                 count+=1
                 num = num/2
            division=division*( count + 1 )
            div = 3
            while num != 1:
                count = 0
                while num%div==0:
                        count+=1
                        num = num/div
                division = division( count + 1)
                div+=2
        return division
    def Find_Number(self, limitdivision):
        self.limitdivision = limitdivision 
        n = 1
        inum , fnum = FindMaxNumber.Find_Division(n) , FindMaxNumber.Find_Division(n+1)
        while inum*fnum < limitdivision:
            n+=1
            inum , fnum = fnum , FindMaxNumber.Find_Division(n+1)
        return inum
    def Final_Result(self , index):
        self.index = index
        num = FindMaxNumber.Find_Number(index)
        final = (num(num+1)/2)
        return final
if __name__=="__main__": main()

谁能告诉我支持用这段代码做什么?

4

1 回答 1

1

您正在调用类上的方法。您可能想改为调用它self

num = self.Find_Number(index)

这适用FindMaxNumber.于您方法中的所有引用;调用实例上的方法,除非你有一个非常具体的理由在类上调用它们,在这种情况下,你需要显式地传入一个实例作为第一个参数。

于 2013-08-02T17:06:33.243 回答