<分区>
Python3: TypeError: 'int' object is not callable
,是不是我调用方法.area()
的方式不对?还是因为我定义 .area()
的方式不对?谢谢
class Rectangle:
def __init__ (self):
self.height = 0
self.width = 0
self.area = 0
def setData(self, height, width):
self.height = height
self.width = width
def area(self, height, width):
self.area = height * width
def __str__(self):
return "height = %i, width = %i" % (self.height, self.width)
return "area = %i" % self.area
if __name__ == "__main__":
r1 = Rectangle()
print (r1)
r1.setData(3,4)
print (r1)
这里我调用了.area()
,我想问题出在哪里:
r1.area(3,4)
print (r1)