>>> class A():
def __init__(self,a,b):
self.a = a
self.b = b
def add(self):
return self.a + self.b
>>> count = A(4,5)
>>> print(count.add())
9
>>>
init两边是各有2个下划线‘_’
>>> class A():
def __init__(self,a,b):
self.a = a
self.b = b
def add(self):
return self.a + self.b
>>> count = A(4,5)
>>> print(count.add())
9
>>>
init两边是各有2个下划线‘_’
转载于:https://www.cnblogs.com/fjwzq/p/5473754.html