python报错:getattribute

LeeMTsc 2020-10-16 10:12:39

class Rectangle:
def __init__(self, width=0, height=0):
self.width =width
self.height =height

def __setattr__(self, name, value):
if name == "square":
self.width =value
self.height = value
else:
super().__setattr__(name, value)

def getArea(self):
return self.width * self.height





报错:
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute
getattribute


问题:一运行该程序就会出现上面结果。跟着视频上学的,不知道怎么出错了。求大神指教!
...全文
207 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
欢乐的小猪 2020-10-20
  • 打赏
  • 举报
回复
你的代码不完整,巧妇难为无米之炊
秋千Swing0_0 2020-10-19
  • 打赏
  • 举报
回复
截个完整的代码图和错误图吧

37,717

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧