在写继承子类的时候出现了TypeError: super() takes at least 1 argument (0 given)的error;

源代码(python3中完美可运行):

class Example(QWidget):

    def __init__(self):
super().__init__() self.initUI() #界面绘制交给InitUi方法

原因是super().__init__()函数在python3中支持,是正确的,但是放到python2中会出现问题;

如果在python2想要继承父类的构造方法,则需要给super参数中传入参数:super(Example,self).__init__();

python2中需这样写:

class Example(QWidget):

    def __init__(self):
super(Example,self).__init__() self.initUI() #界面绘制交给InitUi方法

python运行出现TypeError: super() takes at least 1 argument (0 given)错误的更多相关文章

  1. 【转】python 调用super()初始化报错“TypeError: super() takes at least 1 argument”

    一.实验环境 1.Windows7x64_SP1 2.Anaconda2.5.0 + python2.7(anaconda集成,不需单独安装) 二.实验步骤 2.1 在python中有如下代码: cl ...

  2. appium+python运行自动化测试提示“find_element() takes from 1 to 3 positional arguments but 14 were given”错误

    1.运行后提示"find_element() takes from 1 to 3 positional arguments but 14 were given",在网上找了很多解决 ...

  3. python报错 TypeError: a() got multiple values for argument 'name'

    [问题现象] 在一次调用修饰函数中出现了问题,折腾了一下午,一直报错 TypeError:  got multiple values for argument 只是很简单的调用 from tsu2Ru ...

  4. <转>Python运行的17个时新手常见错误小结

    1)忘记在 if , elif , else , for , while , class ,def 声明末尾添加 :(导致 “SyntaxError :invalid syntax”) 该错误将发生在 ...

  5. Python运行的17个时新手常见错误小结

    1)忘记在if , elif , else , for , while , class ,def 声明末尾添加 :(导致“SyntaxError :invalid syntax”) 该错误将发生在类似 ...

  6. Python基础-TypeError:takes 2 positional arguments but 3 were given

    Error: 今天写一段简单类定义python代码所遇到报错问题:TypeError: drive() takes 2 positional arguments but 3 were given 代码 ...

  7. Python中错误之 TypeError: object() takes no parameters、TypeError: this constructor takes no arguments

    TypeError: object() takes no parameters TypeError: this constructor takes no arguments 如下是学习python类时 ...

  8. 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__() 当调 ...

  9. python:TypeError: main() takes 0 positional arguments but 1 was given

    TypeError: main() takes 0 positional arguments but 1 was given def main(self): 括号里加上self就好了

随机推荐

  1. VPB测试 使用Osgdem运行例子

    1.Osgdem运行例子所需数据下载地址: http://www.cc.gatech.edu/projects/large_models/ps.html Download Elevation Map: ...

  2. Qt编写气体安全管理系统9-数据查询

    一.前言 数据查询模块在整个系统中难度最低,由于Qt对数据库操作的封装堪称完美,所以各种查询都是手到擒来,不费吹灰之力.Qt中内置了sqlite数据库,你可以在数据库插件目录sqldrivers发现q ...

  3. Python核心编程(第二版)PDF

    Python核心编程(第二版) 目录 第1部分 Python核心第1章 欢迎来到Python世界1.1 什么是Python1.2 起源1.3 特点1.3.1 高级1.3.2 面向对象1.3.3 可升级 ...

  4. Redis常用数据类型及各种数据类型应用和实现方式

    Redis常用数据类型: StringHashListSetSorted set 在具体描述这几种数据类型之前,我们先通过一张图了解下Redis内部内存管理中是如何描述这些不同数据类型的: 首先Red ...

  5. Git出现There is no tracking information for the current branch提示的解决办法

    参考:https://blog.csdn.net/sinat_36246371/article/details/79738782 在执行git pull的时候,提示当前branch没有跟踪信息: Th ...

  6. jpa序号/数字占位符?1/?2

    这里的入参nodeId对应占位符?1,入参severity对应?2:缺点是,序号必须是顺序的,按参数顺序严格对应 @Modifying @Transactional @Query(value = &q ...

  7. MySQL的索引有哪些

    一.索引是什么 索引,在MySQL中也叫“键(key)”,是存储引擎用于快速找到记录的一种数据结构.如果把数据库的一张表比作一本书,那索引则是这本书的目录,通过目录,我们能快速找到我们想要的主题所对应 ...

  8. 6.2.3 reginst中的yzm

    @RequestMapping("/reginst/{yzm}") public Object reginst(User user,@PathVariable String yzm ...

  9. STAR软件的学习

    下载地址与参考文档 https://github.com/alexdobin/STAR/archive/2.5.3a.tar.gz wget https://github.com/alexdobin/ ...

  10. PHP 与操作判断奇偶

    /** * 判断奇偶数 * @param $n * @return int */ function isOdd($n){ // $a & $b And(按位与) 将把 $a 和 $b 中都为 ...