TypeError: method() takes 1 positional argument but 2 were given

前端 未结 9 1124
孤街浪徒
孤街浪徒 2020-11-22 05:02

If I have a class...

class MyClass:

    def method(arg):
        print(arg)

...which I use to create an object...

my_objec         


        
9条回答
  •  春和景丽
    2020-11-22 05:51

    You should actually create a class:

    class accum:
        def __init__(self):
            self.acc = 0
        def accumulator(self, var2add, end):
            if not end:
                self.acc+=var2add
        return self.acc
    

提交回复
热议问题