在写继承子类的时候出现了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. linux后台启动springboot并指定日志文件名称

    如果用nohup启动jar包的话,默认的日志文件就是nohup.out,那么如果启动多个jar包的话,看日志文件就麻烦了,因为他们都会写入到nohup.out文件中. 所以我们来指定一下不同jar包的 ...

  2. Spring cloud微服务安全实战_汇总

    Spring cloud微服务安全实战 https://coding.imooc.com/class/chapter/379.html#Anchor Spring Cloud微服务安全实战-1-1 课 ...

  3. Python机器学习实践指南pdf (中文版带书签)、原书代码、数据集

    Python机器学习实践指南 目 录 第1章Python机器学习的生态系统 1 1.1 数据科学/机器学习的工作 流程 2 1.1.1 获取 2 1.1.2 检查和探索 2 1.1.3 清理和准备 3 ...

  4. sed替换字符串(变量)

    sed “s/查找字段/替换字段/g” echo helloworld|sed  ‘s/hello/world/g’ sed 替换字符串以变量形式 1.sed命令使用双引号的情况下,可以使用$var( ...

  5. Spring4.X整合redis

    包和版本的依赖关系很严重 我的配置 spring-data-redis-1.6.6.RELEASE.jar spring-tx-4.2.5.RELEASE.jar redis-2.7.2.jar co ...

  6. 【docker 使用】基本docker命令

    查看镜像 docker images 删除镜像 docker rmi [镜像id的前5位]或[镜像name:镜像tag] 如果有两个镜像指向同一个id,则使用镜像id进行删除时会报错,需要使用name ...

  7. Windows2008R2+iis7.5环境下的dz论坛X3版伪静态设置教程

    Windows2008R2+iis7.5环境下的dz论坛X3版伪静态设置教程 因为2008R2不是那么的普及,加上X3版新出不久,所以伪静态的设置教程比较少,今天搞出来了,其实很简单,那么下面给大家简 ...

  8. 06点睛Spring MVC 4.1-文件上传

    6.1 文件上传 在控制器参数使用@RequestParam("file") MultipartFile file接受单个文件上传; 在控制器参数使用@RequestParam(& ...

  9. 微信小程序 之页面跳转

    wxml: <view><button bindtap="abc" >跳转</button></view> js: abc: (e) ...

  10. [转帖]UCloud上市:利润暴跌84%、成本居高不下,结构化调整迫在眉睫

    UCloud上市:利润暴跌84%.成本居高不下,结构化调整迫在眉睫 https://www.iyiou.com/p/116317.html     [ 亿欧导读 ] 日前,上交所科创板上市委召开第27 ...