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 ...
随机推荐
- bzoj1008
题解: 要求有几种方案可以越狱,可以用总方案-不会越狱的方案 那么总方案就是m^n 那么考虑不会越狱的方案 显然第一个人有m中,后面都是m-1中(和前一个不一样) 答案就是m^n-m*(m-1)^(n ...
- 2017广东工业大学程序设计竞赛决赛 Problem E: 倒水(Water) (详解)
倒水(Water) Description 一天,CC买了N个容量可以认为是无限大的瓶子,开始时每个瓶子里有1升水.接着~~CC发现瓶子实在太多了,于是他决定保留不超过K个瓶子.每次他选择两个当前含水 ...
- 软工作业No.4
2048小游戏—设计开发 软件需求规格说明书 甜美女孩 2018年10月 ——————————————————————————— 文档修改记录 日期 版本 说明 作者 2018-10-18 V1. ...
- windows 开发者神器 tc – total command和替代品
作为开发者,windows上开发时,会运用一些神器,比如:total commander,搜索目录.查看文件.批量重命名等非常方便. tc是收费版的,有个免费的替代版本Just manager:htt ...
- L224
Astronomers have revealed details of mysterious signals emanating from a distant galaxy, picked up b ...
- Linux更改中国时区
执行tzselect命令-->选择Asia-->选择China-->选择east China - Beijing, ->然后输入1 再执行 ln -sf /usr/share/ ...
- nw 注册快捷键
var option = { key : "Escape", }; var shortcut = new gui.Shortcut(option); gui.App.registe ...
- LCD常用接口原理概述
Android LCD(5) 平台信息:内核:linux2.6/linux3.0系统:android/android4.0 平台:samsung exynos 4210.exynos 4412 .e ...
- Android 运行 Linux 可执行程序
/**************************************************************************** * Android 运行 Linux 可执行 ...
- virtualenv 设置虚拟环境来运行不同版本的python
转自: http://pythonguidecn.readthedocs.io/zh/latest/dev/virtualenvs.html virtualenv 是一个创建隔绝的Python环境的 ...