为什么python3.5.2中,下面这段代码会报错
来源:

kkk2
2016-11-24
class IntTuple(tuple):
def __init__(self, iterable):
print(iterable)
# before
super().__init__(iterable)
# after
t = IntTuple([1, -1, 'abc', 6, ['x', 'y'], 3])
print(t)
写回答
2回答
-
程序员硕
2016-11-26
实际tuple并没有__init__方法, 他继承object.__init__, 调用他时不能传除对象以为的参数.
和在继承自object的自定义类的__init__中, 调用super()的__init__一样.
00 -
kkk2
提问者
2016-11-24
object.__init__() takes no parameters 报了这个错
00
相似问题