Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 对象。\uuuu new\uuuuu不接受任何参数_Python - Fatal编程技术网

Python 对象。\uuuu new\uuuuu不接受任何参数

Python 对象。\uuuu new\uuuuu不接受任何参数,python,Python,我在一段python代码中不断遇到以下错误: Traceback (most recent call last): File"..."...in <module> app = App(root) TypeError: object.__new__() takes no parameters 我知道类似的问题也被贴到了这个问题上,但我仍然不完全理解如何解决这个问题-有人知道它为什么出现或者如何解决吗?您的\uuu init\uuu()函数拼写错误 替换 def

我在一段python代码中不断遇到以下错误:

Traceback (most recent call last):     
File"..."...in <module>   
app = App(root)  
TypeError: object.__new__() takes no parameters  
我知道类似的问题也被贴到了这个问题上,但我仍然不完全理解如何解决这个问题-有人知道它为什么出现或者如何解决吗?

您的
\uuu init\uuu()
函数拼写错误

替换

def\uuu init(self,master):
with

def\uuuu初始化(self,master):

确保单词init前后都有双底栏。这些函数称为“dunder”方法,正如您所看到的,底杆的数量确实很重要


Python查找
\uuuuu init\uuuuu
的实现,但找不到它,因此它使用
对象的
\uuuuuu init\uuuuuu
,它只检查是否根据post向它传递了任何参数。此检查导致您看到的
类型错误。

self.t_conv.ScaleAndOffsetConverter
也将失败Raspberry Pi及其Debian派生与此问题无关。我假设您添加它们是因为您正在那里运行代码,但是除非它实际上与操作系统相关,否则请不要添加这些标记。此外,我希望
defconvert(self)
的缩进只是一个格式错误。。。
from tkinter import *
from ScaleAndOffsetConverter import *

class App():
    def __init_(self, master):

        self.c_var = DoubleVar()
        self.t_conv.ScaleAndOffsetConverter("F", "C", 1.8, 32)
        frame = Frame(master)
        frame.pack()
        L1 = Label(frame, textvariable = self.result_var)
        L2 = Label(frame, text = "Deg C")
        E = Entry(frame, textvariable=self.c_var)
        L3 = Label( frame, text = "Deg F")
        B = Button(frame, text = "convert", command = self.convert)
        L1.grid(row=1,column=1)
        L2.grid(row=1, column=0)
        E.grid(row=0, column=1)
        L3.grid(row=0,column=0)
        B.grid(row=2, columnspan=2)
        self.result_var = DoubleVar

     def convert(self):
           c = self.c_var.get()
           self.result_var.set(self.t_conv.convert(c))

root = Tk()
app = App(root)
root.wm_title("Temp Converter")
root.mainloop()