class base_model(object):
def __init__(self):
super().__init__()
运行的时候报错TypeError: super() takes at least 1 argument (0 given)
原因是super().__init__()函数在python3中支持,是正确的,但是放到python2中会出现问题;
如果在python2想要继承父类的构造方法,则需要给super参数中传入参数:super(base_model,self).__init__();
python2中需这样写:
class base_model(object):
def __init__(self):
super(base_model,self).__init__()
Python2与Python3中super()用法区别
2217

被折叠的 条评论
为什么被折叠?



