我试图了解Python 2.7类中<iframe allowfullscreen="" frameborder="0" height="270" src="https://www.youtube.com/live_chat?v=hHW1oY26kxQ&embed_domain=localhost" width="480"></iframe><br />
和__init__
之间的区别
我有以下示例代码:
__new__
我有问题:
obj = super()。新(cls) TypeError:super()至少接受1个参数(给定0个参数)
class Point(object):
def __new__(cls,*args,**kwargs):
print("From new")
print(cls)
print(args)
print(kwargs)
# create our object and return it
obj = super().__new__(cls)
return obj
def __init__(self,x = 0,y = 0):
print("From init")
self.x = x
self.y = y
p = Point(2,3)
的行,则super()
似乎没有运行,因为看不到它的打印语句。有什么想法吗?