Python 定义类中的方法

来源:互联网 发布:c语言求n的阶乘 编辑:程序博客网 时间:2024/06/05 06:26

class MyClass:

def method(self):

print("定义了对象方法");


@staticmethod

def method(self):

print("定义了静态方法");


@classmethod

def method(cls):

print("定义了类方法");


0 0
原创粉丝点击