__init__ and arguments in Python

前端 未结 6 1346
我寻月下人不归
我寻月下人不归 2021-01-31 14:53

I want to understand arguments of the constructor __init__ in Python.

class Num:
    def __init__(self,num):
        self.n = num
    def getn(self)         


        
6条回答
  •  逝去的感伤
    2021-01-31 15:18

    Every method needs to accept one argument: The instance itself (or the class if it is a static method).

    Read more about classes in Python.

提交回复
热议问题