|
本帖最后由 mothecoolest 于 2019-7-26 10:07 编辑
代码:
class Restaurant():
"""A simple attempt to model a restaurant"""
def __init__(self,name,type):
"""Initialize name and type of a restaurant."""
self.name=name
self.type=type
def describe_restaurant(self):
"""describe restaurant"""
print("The restaurant is called "+ self.name.title() +" and it serves "
+ self.type + " food.")
def open_restaurant(self):
"""tell people the restaurant is open"""
print(self.name.title() + " is open!")
class Ice_cream(Restaurant):
"""A model of ice cream stand inherance from Class Restaurant"""
def __init__(self,name,type):
"""Initialize attributes of Restaurant"""
super.__init__(name,type)
def describe_icecream(self):
"""describe restaurant"""
print("The ice cream stand is called "+ self.name.title() +" and it serves "
+ self.type + " of ice cream.")
my_ice_cream=Ice_cream('Mooth','Chocolate')
错误反馈:
Traceback (most recent call last):
File "9_5.py", line 25, in <module>
my_ice_cream=Ice_cream('Mooth','Chocolate')
File "9_5.py", line 19, in __init__
super.__init__(name,type)
TypeError: descriptor '__init__' requires a 'super' object but received a 'str'
|
|