无参数

类 / 方法

class Greeting:
    # self 是唯一的参数
    def say_goodbye(self):
        print("Goodbye!")

    # 完全没有参数:静态方法
    @staticmethod
    def say_hello():
        print("Hello!")


greeting = Greeting()
greeting.say_goodbye()

Greeting.say_hello()