注意是__init__不是__int__

class HotDog:
    def __init__(self):
        self.cooked_level = 0
        self.cooked_string = "Raw"
        self.condiments = []
    def cook(self,time):
        self.cooked_level = self.cooked_level + time
        if self.cooked_level > 8:
            self.cooked_string = "Charcoal"
        elif seif.cooked_level > 5:
            self.cooked_string = ":Well-done"
        elif self.cooked_level > 3:
            self.cooked_string = "Medium"
        else:
            self.cooked_string = "Raw"
myDog = HotDog()
print myDog.cooked_level
print myDog.cooked_string
print myDog.condiments
第十四章 对象-注意是__init__不是__int__

相关文章:

  • 2021-06-07
  • 2021-11-20
  • 2021-11-01
  • 2021-10-16
  • 2021-11-14
  • 2021-09-21
  • 2022-01-04
猜你喜欢
  • 2021-10-07
  • 2021-11-13
  • 2022-12-23
  • 2021-11-23
  • 2021-08-03
  • 2021-07-01
相关资源
相似解决方案