Python:TypeError:';浮动';对象不可调用

Python:TypeError:';浮动';对象不可调用,python,types,Python,Types,我正在尝试使用以下代码连接两个字符串: def __get_temp(self): return float(self.ask('RS')) def __set_temp(self, temp): set = ('SS' + repr(temp)) stat = self.ask(set) return self.check(stat) temp = property(__get_temp, __set_temp) 在一起之后,我使用PyVisa通过串行总线

我正在尝试使用以下代码连接两个字符串:

def __get_temp(self):
    return float(self.ask('RS'))

def __set_temp(self, temp):
    set = ('SS' + repr(temp))
    stat = self.ask(set)
    return self.check(stat)

temp = property(__get_temp, __set_temp)
在一起之后,我使用PyVisa通过串行总线发送信号。然而,当我尝试调用该函数时,我得到

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
chil.temp(13)
TypeError: 'float' object is not callable
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
儿童温度(13)
TypeError:“float”对象不可调用

我试着四处寻找这个错误的解释,但没有一个是有意义的。有人知道发生了什么吗?

看起来您正在尝试设置属性temp,但实际上您正在获取属性,然后尝试使用参数13将其作为函数调用。设置的语法为:

chil.temp = 13
这一行:
set=('SS'+repr(temp))
将给您带来痛苦。。。您正在重写一个内置类型。(虽然这不是您当前问题的原因。)