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__()
Python super(Todo,self).__init__() TypeError: super() argument 1 must be type, not classobj的更多相关文章
- 【转】python 调用super()初始化报错“TypeError: super() takes at least 1 argument”
一.实验环境 1.Windows7x64_SP1 2.Anaconda2.5.0 + python2.7(anaconda集成,不需单独安装) 二.实验步骤 2.1 在python中有如下代码: cl ...
- TypeError: Fetch argument 0 has invalid type <type 'int'>, must be a string or Tensor. (Can not convert a int into a Tensor or Operation.)
6月5日的時候,修改dilated_seg.py(使用tensorflow)出現了報錯: TypeError: Fetch argument 0 has invalid type <type ' ...
- TypeError: Fetch argument None has invalid type <type 'NoneType'>
(fetch, type(fetch)))TypeError: Fetch argument None has invalid type <type 'NoneType'> 我的解决方案是 ...
- python运行出现TypeError: super() takes at least 1 argument (0 given)错误
在写继承子类的时候出现了TypeError: super() takes at least 1 argument (0 given)的error: 源代码(python3中完美可运行): class ...
- python中的super( test, self).__init__()
python中的super( test, self).__init__() 对继承自父类的属性进行初始化 首先找到test的父类(比如是类A),然后把类test的对象self转换为类A的对象,然后“被 ...
- python高级编程之超类02:super的缺陷
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' #当使用多重继承层次结构时,再使用super的时候是非常危险的,主要 ...
- Python 类继承,__bases__, __mro__, super
Python是面向对象的编程语言,也支持类继承. >>> class Base: ... pass ... >>> class Derived(Base): ... ...
- python基础-9.1 面向对象进阶 super 类对象成员 类属性 私有属性 查找源码类对象步骤 类特殊成员 isinstance issubclass 异常处理
上一篇文章介绍了面向对象基本知识: 面向对象是一种编程方式,此编程方式的实现是基于对 类 和 对象 的使用 类 是一个模板,模板中包装了多个“函数”供使用(可以讲多函数中公用的变量封装到对象中) 对象 ...
- python 面向对象(六)MRO C3算法 super
########################总结################ 面向对象回顾 类:对某一个事物的描述,对一些属性和方法的归类 class 类名: var=123#类变量 def ...
随机推荐
- 2. Go并发编程--GMP调度
目录 1. 前言 1.1 Goroutine 调度器的 GMP 模型的设计思想 1.2 GMP 模型 1.3. 有关M和P的个数问题 1.4 P 和 M 何时会被创建 2. 调度器的设计策略 3. g ...
- Influxdb数据库 - 基本操作
InfluxDB数据库的简介 InfluxDB是一个用于存储和分析时间序列数据的开源数据库,是一个基于 golang 编写,用于记录 metrics.events,进行数据分析. 主要特性有: 内置H ...
- 低代码+RPA+AI,能否让ERP焕发下一春?
从2004年开始,国内ERP项目的实施便在各大企业热火朝天地展开,2014年,国内大中型企业已经基本完成了ERP系统的普及.ERP已经在大中型企业中成为不可或缺的关键信息系统.企业核心业务的流转与管控 ...
- Oracle Haip无法启动问题学习
一.目标:Oracle Haip 启动报错 需求:日常运维过程中,已经遇到两次由于HAIP引发的问题,特此进行记录. 本次问题是看着大佬-李海清操作,整完了记录一下,上一次HAIP折腾了4个小时. O ...
- Gitee自动化部署python脚本
一.前期准备 1.1 安装环境 1.安装python3 2.打开命令行安装selenium pip install selenium 二.python代码 2.1 源码 #!/usr/bin/pyth ...
- ❤️❤️爆肝3万字整理小白快速入门分布式版本管理软件:Git,图文并茂(建议收藏)--已码一万字❤️❤️
@ 目录 什么是Git SVN VS Git 什么是版本控制 安装Git 谁在操作? Git本地仓库 本地仓库构造 重点 Git基本操作 git add git commit git diff git ...
- IceCream in Python
IceCream in Python 你还在使用print 在Python 中 debug 吗?赶快使用Icecream吧. 提到 Icecream,你是不是会想到ta? 动机 如果你使用print去 ...
- Windows下Vim插件管理器Vundle的安装以及使用简介
Vundle下载 从GitHub clone仓库 cd %USERPROFILE% git clone git@github.com:VundleVim/Vundle.vim.git %USERPRO ...
- PyTorch固定参数
In situation of finetuning, parameters in backbone network need to be frozen. To achieve this target ...
- 踩坑系列《三》 java -version 报错出现Error occurred during initialization of VM java/lang/NoClassDefFoundError:
之前导入一个项目,因为该项目Spring版本过低,只能适用于1.7版本,装了jdk1.7版本.安装配置好后,打开cmd窗口,执行 java -version 指令发现没像正常一样显示版本信息,而是报了 ...