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 ...
随机推荐
- XE里, TStringField 还是 ansi的
{ TStringField } TStringField = class(TField) private FFixedChar: Boolean; FTransliterate: Boolean; ...
- 玩转X-CTR100 l STM32F4 l ESP8266串口WIFI模块
我造轮子,你造车,创客一起造起来!更多塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ]- ESP8266是一款非常火的WIFI模块,性价 ...
- 背景 半透明问题 rgba + filter
<html style=" background: violet;"><head><meta charset="utf-8"> ...
- 3.1 shell简介、变量、运算符
小知识: ipcs可以查看系统中创建的ipc进程间通信资源,例如信号量.共享内存等.示例如下: 什么是shell? shell是核心程序kernel之外的指令解析器,是一个程序,同时是一种命令语言和程 ...
- Ubuntu16.04 和 hadoop2.7.3环境下 hive2.1.1安装部署
参考文献: http://blog.csdn.NET/reesun/article/details/8556078 http://blog.csdn.Net/zhongguozhichuang/art ...
- 分享一个使用 vue.js 开发的网站
点我 惠淘党 照着文档和google开发,只花了一个多星期.依赖包如下 { "name": "vue-htd", "version": &q ...
- matlab reshape()、full()
一.reshape() 对于这个函数,就是重构矩阵. (1)要求:重构前后的矩阵元素个数一致.如3*4矩阵可以重构成2*6,2*3*2等. (2)重构方法:先按列将矩阵转换为向量,然后在向量的基础之上 ...
- linux-*.filetype.bz2 unzip
how to unzip *.bz2 file? wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2 unzip ...
- 怎样取消老毛桃软件赞助商---只需在输入框中输入老毛桃官网网址“laomaotao.org”
来源:www.laomaotao.org 时间:2015-01-29 在众多网友和赞助商的支持下,迄今为止,老毛桃u盘启动盘制作工具已经推出了多个版本.如果有用户希望取消显示老毛桃软件中的赞助商,那不 ...
- ZOJ 3432 Find the Lost Sock (异或的运用)
Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lost ...