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 ...
随机推荐
- macOS 使用brew安装mysql,客户端连接不上
macos 使用brew安装mysql8.0后,使用mysql官方的workbench连接不上,出现√ mysql8.0 Authentication plugin 'caching_sha2_pas ...
- postman--安装及Interceptor插件
1. 官网安装(看网速-我下载的时候一直下载失败) 打开官网,https://www.getpostman.com 选择ios或者win 2. 非官网安装 https://pan.baidu. ...
- P1002 谁拿了最多奖学金
P1002 谁拿了最多奖学金 时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 NOIP2005复赛提高组第一题 描述 某校的惯例是在每学期的期末考试之后发放奖 ...
- 重构Tips
一,重新组织函数1.首先找出局部变量和参数. 1>任何不会被修改的变量都可以当作参数传入.2.去掉临时变量Replace Temp with Query.用查询函数代替临时变量3.Extract ...
- buy now按钮的添加
样例是 www.dealfreeship.com:在D:\xampp\htdocs\aliexpress\app\design\frontend\default\se101\template\cata ...
- BZOJ3551: [ONTAK2010]Peaks加强版【Kruskal重构树】【主席树】
重要的事情说三遍 不保证图联通 不保证图联通 不保证图联通 那些和我一样认为重构树是点数的童鞋是要GG Description [题目描述]同3545 Input 第一行三个数N,M,Q. 第二行N个 ...
- CTF中图片隐藏文件分离方法
CTF中图片隐藏文件分离方法 0x01 分析 这里我们以图片为载体,给了这样的一样图片:2.jpg 首先我们需要对图片进行分析,这里我们需要用到kali里面的一个工具 binwalk ,想要了解这 ...
- POJ3276(遍历+区间修改)
http://poj.org/problem?id=3276 题意:n(n<=5000)头牛站成线,有朝前有朝后的的,然后每次可以选择大小为k的区间里的牛全部转向,会有一个最小操作m次使得它们全 ...
- hdu2085-2086
hdu2085 模拟 #include<stdio.h> ][]; void fun(){ a[][]=; a[][]=; ;i<=;i++){ a[i][]=*a[i-][]+*a ...
- hdu1243 dp (类最长公共子序列)
题意:射击演习中,已知敌人出现的种类顺序,以及自己的子弹种类顺序,当同种类的子弹打到同种类的敌人时会得到相应分数,问最多能得多少分. 这题的题意很好理解,而且模型也很常见,是带权值的类最长公共子序列问 ...