初学python
导入的模块:
class Restaurant:
def init(self,restaurant_name,cuisine_type):
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
def describe_restaurant(self):
print(f"{self.restaurant_name}\n{self.cuisine_type}")
def open_restaurant(self):
print(f"The restaurant {self.restaurant_name} is open. ")
class IceCreamStand(Restaurant):
def init(self,restaurant_name,cuisine_type):
super().init(restaurant_name,cuisine_type)
self.flavors = ['strawberry','watermellon','apple']
def describe_flavors(self):
for key in self.flavors:
print(key)
IceCreamStand_1 = IceCreamStand('Alice','sweet')
IceCreamStand_1.describe_flavors()
被导入:
from practice9_6 import Restaurant
运行结果:
strawberry
watermellon
apple