我读过其他问题,解释了__init__
和之间的区别,__new__
但是我不明白为什么在下面的代码中使用python 2 out:
init
和Python3:
new
init
示例代码:
class ExampleClass():
def __new__(cls):
print ("new")
return super().__new__(cls)
def __init__(self):
print ("init")
example = ExampleClass()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句