[英]Python2 and Python3: __init__ and __new__
我已经阅读了其他问题来解释__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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.