【发布时间】:2015-10-24 16:32:16
【问题描述】:
我已经阅读了其他解释 __init__ 和 __new__ 之间区别的问题,但我只是不明白为什么在以下代码中使用 python 2 输出:
init
和 Python3:
new
init
示例代码:
class ExampleClass():
def __new__(cls):
print ("new")
return super().__new__(cls)
def __init__(self):
print ("init")
example = ExampleClass()
【问题讨论】:
-
python2 示例的语法错误
标签: python python-3.x python-2.x init super