[英]Returing tuple giving an error tuple object is not callable
class Foo:
def __init__(self):
pass
@property
def get_features(self):
return (1,2,3,)
def execute(self):
print self.get_features()
f = Foo()
f.execute()
我得到:
TypeError: 'tuple' object is not callable
我感興趣的實際上是該元組的長度。
原因是您在get_features()函數上具有@property裝飾器,使其成為屬性,因此無法調用。
這意味着execute()只需打印屬性,而不是將其作為函數調用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.