def__int__(self, restaurant_name, cuisine_type): self.restaurant_name=restaurant_name self.cuisine_type=cuisine_type defdescribe_restaurant(self): print("The "+self.restaurant_name+" have "+ str(self.cuisine_type)+" kinds of food.") defopen_restaurant(self): print("Now is opening.") ...
哈哈,因为你的初始化方法写错了,应该是两个下划线,而你只输入了1个:_init_改为__init__即可。输出结果为:233 455 营业中
classRestaurant:def_init_(self,restaurant_name,cuisine_type):***.name=restaurant_nameself.type=cuisine_typedefdes_restaurant(self):print(***.name)print(self.type)defope... class Restaurant:def _init_(self,restaurant_name,cuisine_type):***.name=restaurant_nameself.type=cuisine_typedef des_res...