class C:
name='fdsa'
def __init__(self,name,age):
print('init')
self.name=name
self.age=age
@staticmethod
def test2():
print('pass')
@classmethod
def test(cls):
print('cls')
return cls.test2()
def test3(self):
return C.name
A = C('cheyunhua',59)
print(A.test())
python 类方法
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
下一篇:Java重载与重写
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python 类方法Python开发 Python学习
-
python 类 方法 python中类方法
Python中至少有三种比较常见的方法类型,即实例方法,类方法、静态方法。
python 类 方法 静态方法 类方法 实例方法