class Demo(object):
def __init__(self):
print('__init__() called...')
def __new__(cls, *args, **kwargs):
cls.print(cls)
return object.__new__(cls, *args, **kwargs)
def print(cls):
print("2123")
if __name__ == '__main__':
de = Demo()
Python 中的 __new__(cls)方法
最新推荐文章于 2024-01-04 13:26:10 发布