AttributeError:“Michael”对象没有属性“\u class\u”

2024-10-01 07:10:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚开始学习Python,这里有个问题。我从课本上抄了下面的代码,所以我应该继续学习

class Michael:
    def _init_(self,max):
        self.count = 0
        self.max = 5

    def teach(self):
        if self._class_.count < self._class_max:
            print("play harder!")
        else:
            print("Well done!")
        self._class_count += 1

oni1 = Michael()
for i in range(4):
    print("smash!")
    oni1.teach()
oni2 = Michael()
for i in range(2):
    print("backstroke")
oni2.teach()

但是我的编辑给了我下面的信息。 (AttributeError:'Michael'对象没有属性“class”) 另外,它还说16号线也错了,尽管它没有告诉我我是怎么犯错的。如果您能为我提供上述问题的解决方案,我将不胜感激


Tags: 代码inselffordefcountrangemax