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 ...
随机推荐
- DevExpress v18.1新版亮点——WinForms篇(四)
用户界面套包DevExpress v18.1日前终于正式发布,本站将以连载的形式为大家介绍各版本新增内容.本文将介绍了DevExpress WinForms v18.1 的新功能,快来下载试用新版本! ...
- 使用MyEclipse开发Java EE应用:用XDoclet创建EJB 2 Session Bean项目(四)
MyEclipse限时秒杀!活动火热开启中>> [MyEclipse最新版下载] 四.运行XDoclet代码生成 通常每次更改XDoclet EJB配置.应用程序服务器设置或修改任何EJB ...
- MySQL主从数据一致性问题修复
MySQL主从数据一致性问题修复 前面,我们使用pt-table-checksum 可以检测出主从数据是否一致的问题.发现问题后,我们怎么解决这些问题,也是我们必须要会的技能. 修复主从数据一致性问题 ...
- "Incorrect string value: '\\xE7\\x89\\x8C\\xE5\\xB1\\x80...' for column 'name' at row 1")
出现这个错误的原因是,数据库的编码格式为latin1 而我要将utf8的中文插入到数据库中. mysql> alter database xxx default character set ut ...
- vue 设置代理后 后端获取不到登录的session处理方法
代理设置的 名称 必须是 远程后端的 项目名称 session才生效.
- SVN 将主干的代码合并到分支上
来源:http://blog.csdn.net/u012701023/article/details/50978154 问题:开发有了项目主干,再次基础上起了一个分支,开发新的功能:因为业务需要,在上 ...
- [Algorithm] A nonrecursive algorithm for enumerating all permutations of the numbers {1,2,...,n}
def permutationN(n): a=[None]*n for i in range(n): a[i]=i+1 sum=1 for j in range(n): sum*=(j+1) i=0 ...
- TP框架连接mongodb报错及解决办法
mongodb版本3.4.7 1.认证错误:Failed to connect to: localhost:27017: Authentication failed on database 'test ...
- HDU 2544:最短路
最短路 Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- NASSA’s Robot
NASSA的机器人降落到了火星,降落的地方可以用X-Y坐标表示.机器人最开始在(0, 0).由于传输问题,部分指令可能会混淆,现在给出确定的命令与未知命令,请帮忙确认机器人的X.Y坐标最小最大值分别是 ...