TypeError:此构造函数不接受任何参数 [英] TypeError: this constructor takes no arguments

查看:113
本文介绍了TypeError:此构造函数不接受任何参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我是python编码的新手.我在运行代码时遇到问题.这是我的代码.

来自Tkinter import *


i m new in python coding. i got a problem while running my code.this is my code.

from Tkinter import *

class example3:
    def _init_(self, master):
        self.lbl=Label(master, text="press button below to exit")
        self.lbl.pack()
        self.btn=Button(master, text="quit", command= quit)
        self.btn.pack()

        root=Tk()
        ex3=example3(root)
        root.mainloop()
        def quit(self):

        import sys; sys.exit()




这是错误" TypeError:此构造函数不接受参数 ".
请帮帮我.

荣誉
neaS




this is the error "TypeError: this constructor takes no arguments".
please help me out.

kudos
neaS

推荐答案

似乎__init__方法可能未正确覆盖.在单词init之前和之后需要两个下划线,而不仅仅是一个.

另外,从缩进来看,看起来好像是使用自己的__init__方法从创建实例的,还是您跳过了某些地方的代码?

如果可能,请更清楚.
It looks like the __init__ method may not be overridden properly. You need two underscores before and after the word init, not just one.

Also, from the indentation, it looks like the instance is being created from with it''s own __init__ method, or have you skipped some code somewhere?

More clarity, if possible please.


这篇关于TypeError:此构造函数不接受任何参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆