__init__ and arguments in Python

前端 未结 6 1400
我寻月下人不归
我寻月下人不归 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:23

    In python you must always pass in at least one argument to class methods, the argument is self and it is not meaningless its a reference to the instance itself

提交回复
热议问题