zoukankan      html  css  js  c++  java
  • Python super(Todo,self).__init__() TypeError: super() argument 1 must be type, not classobj

    示例如下

    class A():
         def __init__(self):pass
    
    class B(A):
         def __init__(self):
               super(A, self).__init__()
    

    当调用B创建对象时,会出现错误

    TypeError: super() argument 1 must be type, not classobj
    

    python中的super只能应用于新类,而不能应用于经典类。
    新类的意思大概就是要有父类。
    例如

    class B(A):
    

    经典类就是没有父类的类
    例如

    class A():
    

    产生上面问题的原因就是对A类这个经典类调用了

    super(A, self).__init__()
    
  • 相关阅读:
    测试打印功能
    绘图
    图片验证码
    图片防盗
    图片水印
    surface 译
    ViewManager 译
    WindowId 译
    Display
    LayoutParams
  • 原文地址:https://www.cnblogs.com/vercont/p/10210201.html
Copyright © 2011-2022 走看看