这是被调用的模块,我想调用其中的describe_restaurant()。
class Restaurant():
def __init__(self, name, type):
self.restaurant_name = name
self.cuisine_type = type
def describe_restaurant(self):
print("The name of the restaurant is "
+ self.restaurant_name.title() + ".")
print("The cuisine type of the restaurant is "
+ self.cuisine_type.title() + ".")
def open_restaurant(self):
print(self.restaurant_name.title()
+ " is open now.")
restaurant = Restaurant('panda','chinese food')
res2 = Restaurant('tuesday','mexico food')
res3 = Restaurant('thai','thai food')
print(restaurant.restaurant_name)
print(restaurant.cuisine_type)
restaurant.describe_restaurant()
restaurant.open_restaurant()
res2.describe_restaurant()
res3.describe_restaurant()
这是进行调用的模块
from restaurant import Restaurant
res = Restaurant('panda','chinese food')
res.describe_restaurant()
我想得到的输出是
The name of the restaurant is Panda.
The cuisine type of the restaurant is Chinese Food.
而实际输出是
panda
chinese food
The name of the restaurant is Panda.
The cuisine type of the restaurant is Chinese Food.
Panda is open now.
The name of the restaurant is Tuesday.
The cuisine type of the restaurant is Mexico Food.
The name of the restaurant is Thai.
The cuisine type of the restaurant is Thai Food.
The name of the restaurant is Panda.
The cuisine type of the restaurant is Chinese Food.