Python中有关类方法与静态方法的程序,为什么没有输出结果
classMethods(object):@classmethoddefpulicClassMethod(cls):returncls@classmethoddef_pr...
class Methods(object): @classmethod def pulicClassMethod(cls): return cls @classmethod def _privateClassMethod(cls): return cls @staticmethod def publiscStaticMethod(): return 'publish' @staticmethod def _privateStaticMethod(): return 'private' def pulicMethod(self): print('called publicMethod') def _privateMethod(self): print("called privateMethod") publicMethodToClassMethod=classmethod(pulicMethod) privateMethodToClassMethod=classmethod(_privateMethod) publicMethodToStaticMethod=classmethod(pulicMethod) privateMethodToStaticMethod=classmethod(_privateMethod)m=Methods()
展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询