假设我有这样的代码
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
但它不起作用,因为根据错误,该函数本身不可调用。
注意:这只是一个测试函数,我的实际代码比这复杂得多,但我不能只是将它们复制并粘贴到这里,因为阅读它们需要永恒:)