python class 静态方法

‘’’
类的静态方法
‘’’
class Person():
@staticmethod
def shoestyle():
print(‘有无数种’)

if name == ‘main’:
A = Person
A.shoestyle()
‘’’
使用装饰器@staticmethod
类里面的普通函数,不用传递self,cls,也可以被对象调用
‘’’
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44737399/article/details/89083048