Python类没有print语句的输出

2024-10-04 07:35:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在从一本书上学习Python,还上了很多课。当我使用类创建第一个程序时,程序不返回输出,只返回代码0。你知道吗

class Restaurant():

    def __init__(self, restaurant_name, cuisine_type):
        self.restaurant_name = restaurant_name
        self.cuisine_type = cuisine_type

    def describe_restaurant(self):
        print("\nThe restaurant is : " + self.restaurant_name)
        print('\nThe cuisine offered is : '+ self.cuisine_type)

    def open_restaurant():
        print('\n\nThe restaurant is open! ')

rest_1 = Restaurant("Good", 'Indian')
rest_1.describe_restaurant()
print("Hello")

我包括打印(“你好”)只是为了检查输出来或不来,但没有什么。我想我真的把事情搞砸了,这甚至可能是一个相当愚蠢的事情。帮我解决这个问题!你知道吗

谢谢。你知道吗


Tags: nameself程序restisdeftypeopen