赞
踩
- class Restaurant():
- def __init__(self,r_name,cuisine_type):
- '''初始化两个属性'''
- self.r_name=r_name
- self.cuisine_type=cuisine_type
-
- def __describe_restaurant__(self):
- '''将初始化的信息打印出来'''
- print('the restaurant name is '+self.r_name)
- print('the cuisine type is '+self.cuisine_type)
-
- def __open_restaurant__(self):
- '''打印餐馆正在营业'''
- print('餐馆正在营业~')
'运行
myrestautant=Restaurant('张记私房菜','川菜')
print(myrestautant.r_name,myrestautant.cuisine_type)
- myrestautant.__describe_restaurant__()
- myrestautant.__open_restaurant__()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。