属性对象不可调用

假设我有这样的代码

terms

当我打印出 @property def Inverted_string(str): return str[::-1] print(Inverted_string("123")) 时,它给了我一个错误

Inverted_string("123")

如何在不删除此函数上方的 Traceback (most recent call last): File "d:\Python Project\Test.py",line 5,in <module> print(Inverted_string("123")) TypeError: 'property' object is not callable 装饰器的情况下以字符串形式访问 Inverted_string() 的返回值?我尝试了 @property 但它不起作用,因为根据错误,该函数本身不可调用。

注意:这只是一个测试函数,我的实际代码比这复杂得多,但我不能只是将它们复制并粘贴到这里,因为阅读它们需要永恒:)

zgkejizh 回答:属性对象不可调用

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/10922.html

大家都在问