为什么我不能得到结果(肯德基是美国餐馆)?我怎样才能改变它?我符合要求吗?你知道吗
class Restaurant:
__name=""
__cuisine=""
def __init__(self,name,cuisine):
self.__name=name
self.__cuisine=cuisine
def describe_restaurant(self):
print(self.__name, " is a ",self.__cuisine ," restarurant.")
def open_restaurant(self):
print(self.__name ," is open.")
def test():
p=Restaurant("KFC","American")
print(p.describe_restaurant)
describe_restaurant
是一个函数。当你写作的时候你得到的是一个函数的字符串表示。但是,您希望调用这个函数,让它执行,并打印其返回值。为此,请添加括号:
此外,确保实际调用
test
方法,如下所示:相关问题 更多 >
编程相关推荐