方法__init__()
class Restaurant():
def __init__(self,restaurant_name,cuisine_type):
self.restaurant_name=restaurant_name
self.cuisine_type=cuisine_type
方法describe_restaurant()
def describe_restaurant(self):
print(self.restaurant_name.title()+" is a "+self.cuisine_type.title()+" restaurant.")
方法open_restaurant()
def open_restaurant(self):
print("This restaurant is open")
测试
my_restaurant=Restaurant('chuanwei','zhongcan')
my_restaurant.describe_restaurant()
my_restaurant.open_restaurant()