关键字:@staticmethod
class TEST:
@staticmethod #静态方法声明
def test():
print('staticmethod test')
'''静态方法中,可以不用传self参数,也可以依据实际需求传递形参。
调用时,可以不用实例化对象,直接由类调用。'''
例 子:TEST.test()
扫描二维码关注公众号,回复:
825682 查看本文章
输出结果: staticmethod test