class Dog:
def __new__(cls): # 这里传入的cls就是Dog这个类指向的类对象
print('new')
def __init__(self):
print('init')
dog = Dog() # new
print(dog) # None
class Dog:
def __new__(cls): # 这里传入的cls就是Dog这个类指向的类对象
print('new')
def __init__(self):
print('init')
dog = Dog() # new
print(dog) # None
本文标题:python中的__new__(cls)和__init__(se
本文链接:https://www.haomeiwen.com/subject/ctfzactx.html
网友评论