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

前端 未结 9 1138
孤街浪徒
孤街浪徒 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:41

    Pass cls parameter into @classmethod to resolve this problem.

    @classmethod
    def test(cls):
        return ''
    

提交回复
热议问题