【发布时间】:2022-01-20 04:01:24
【问题描述】:
如何解决问题? 我试试:
class plot():
def __init__(self,length,width):
self.length = length
self.width = width
def area(self):
print("area is ",self.length*self.width)
def perimetre(self):
per = 2(self.length+self.width)
print("perimeter is ",per)
a1 , p1 = plot(10,20),(10,20)
a1.area()
p1.perimetre()
得到了这个错误:
<>:10: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
<>:10: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma? <ipython-input-83-8515c6a74849>:10: SyntaxWarning: 'int' object is not callable; perhaps you missed a comma?
per = 2(self.length + self.width)
--------------------------------------------------------------------------- AttributeError
Traceback (most recent call last)
<ipython-input-83-8515c6a74849> in <module>
13
14 a1.area()
---> 15 p1.perimetre()
AttributeError: 'tuple' object has no attribute 'perimetre'
【问题讨论】:
-
正确格式化代码。使用正确的代码格式来包含堆栈跟踪。
标签: python attributes tuples attributeerror