python2.7中出现TypeError: must be type, not classobj
class Person:
def __init__(self,name,age):
self._name = name
self._age = age class Student(Person):
def __init__(self,name,age,id):
super(Student, self).__init__(name,age)
self._id = id
原因:
super只能用于python的新类中,如果基类是经典类,则会报这个错
新类:所有类都必须要有继承的类,如果什么都不想继承,就继承object类。
经典类:什么都不继承的类,如上面的Person就是经典类。所以报错
解决方法:
让Person继承object
class Person(object):
python2.7中出现TypeError: must be type, not classobj的更多相关文章
- python3.x元组打印错误 TypeError: unsupported operand type(s) for %: 'NoneType' and 'tuple'
原创by南山南北秋悲 欢迎引用!请注明原地址:http://www.cnblogs.com/hwd9654/p/5676746.html 谢谢! TypeError: unsupported ope ...
- python pip install 报错TypeError: unsupported operand type(s) for -=: 'Retry' and 'int' Command "python setup.py egg_info" failed with error code 1 in
pip install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl ...
- python2.7中MySQLdb的安装与使用详解
Python2.7中MySQLdb的使用 import MySQLdb #1.建立连接 connect = MySQLdb.connect( '127.0.0.1', #数据库地址 'root', # ...
- TypeError: Object of type 'int64' is not JSON serializable
错误类型:TypeError: Object of type 'int64' is not JSON serializable 错误场景:对Numpy和Pandas结果进行json.dumps报错 错 ...
- python2.7中的字符编码问题
0. 写在前面 起因:之前写个数据预处理程序的时候遇到了点问题,用re模块的正则查找方法search时总是找不出来(找错了或者出乱码),于是捣鼓捣鼓. 经过:查资料,做实验,发现用utf8编码的str ...
- 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__() 当调 ...
- Python3字典中items()和python2.x中iteritems()有什么区别
在Python2.x中,items( )用于 返回一个字典的拷贝列表[Returns a copy of the list of all items (key/value pairs) in D],占 ...
- Python2/3中的urllib库
urllib库对照速查表 Python2.X Python3.X urllib urllib.request, urllib.error, urllib.parse urllib2 urllib.re ...
- TypeError: unsupported operand type(s) for +: 'float' and 'decimal.Decimal'
TypeError: unsupported operand type(s) for +: 'float' and 'decimal.Decimal' 浮点型和双精度类型 相加报错 from deci ...
随机推荐
- 2018-北航-面向对象567次OO作业分析与小结
设计策略及其变化 第五次作业-多线程电梯 在这次作业一开始的大部分时间,我一直想着怎样设计最为完美,完全使用BlockingQueue,导致交作业前发现设计并不能满足指导书的要求.最后仓皇之中加了一个 ...
- L224 词汇题
Elaborate 精心的 preparations were being made for the Prime Minister’s official visit to the four forei ...
- websevice之三要素
SOAP(Simple Object Access Protocol).WSDL(WebServicesDescriptionLanguage).UDDI(UniversalDescriptionDi ...
- C++中特殊的宏定义
常规用法不再介绍,做如下几点说明和介绍 1. 带参数的宏只完成简单字符替换,之前不做计算实参的工作,如下 #define SUM(x,y) x+yint a=3,b=2,c=1;int s;s=SUM ...
- 如何编写Makefile,一份由浅入深的Makefile全攻略
本文转载整理自陈浩大大的文章(跟我一起写 Makefile),由于原文内容庞大,故梳理出目录结构以便于学习及查阅参考. 一.概述 —— 什么是makefile?或许很多Winodws的程序员都不知道这 ...
- Error: timed out while waiting for target halted
/************************************************************************************ * Error: timed ...
- opencv图像读取-imread
前言 图像的读取和保存一定要注意imread函数的各个参数及其意义,尽量不要使用默认参数,否则就像数据格式出现错误(here)一样,很难查找错误原因的: re: 1.opencv图像的读取与保存; 完
- Linux基础和网络管理上机试题 - imsoft.cnblogs
一.(使用at命令实现任务的的自动化,要求用一条条的指令完成) 找出系统中任何以txt为后缀名的文档,并且进行打印.打印结束后给用户foxy发出邮件通知取件.指定时间为十二月二十五日凌晨两点 ...
- 在U盘上安装Windows 7的详细步骤
买到苹果新款MacBook Air后大家最想干的事是什么?体验一下Mac OS X?事实告诉我们有几乎一半的人第一件想要做的事是装一个微软的Windows系统,但问题是新版的MBA已经没有光驱了,这可 ...
- Prime Ring Problem dfs
A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle ...