问题遇到的现象和发生背景
做题,遇到个无法理解的问题,为什么会无法调用
问题相关代码,请勿粘贴截图
class Restauraut(object):
def __init__(self,restaurant_name,cuisine_type):
self.name=restaurant_name
self.type=cuisine_type
def describe_restaurant(self):
print(name,type)
def open_restaurant(self):
print("餐厅正在营业")
restaurant=Restauraut('KEC','Chinese food')
print('餐厅名称:'+restaurant.name())
运行结果及报错内容
Traceback (most recent call last):
File "D:\python\pycharm\pythonProject\class creation.py", line 12, in <module>
print('餐厅名称:'+restaurant.name())
TypeError: 'str' object is not callable