def __init__(self,kind = "cheese"): self.set_kind(kind) return def set_kind(self,kind): possible_ingredients = self.__known_kinds(kind) if possible_ingredients == False: return False else: self.kind = kind self.needed_ingredients = possible_ingredients
以上代码都是Omelet类中的函数
AttributeError: 'Omelet' object has no attribute '_Omelet__known_kinds'如此报错
求助!(鞠躬)
def __known_kinds(self,kind):
if kind == "cheese":
return{"eggs":2,"milk":1,"cheese":1}
elif kind == "mushroom":
return{"eggs":2,"milk":1,"cheese":1,"mushroom":2}
elif kind == "onion":
return{"eggs":2,"milk":1,"cheese":1,"onion":1}
else:
return False
Eric_温水之蛙
Eric_温水之蛙
相关分类