程序猿刚子的博客

大龄程序猿,分享互联网开发相关知识!前端、后端,架构等内容,欢迎关注公众号 chengxuyuangangzi

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年1月20日

摘要: class Student(object): #静态变量 count=0 def __init__(self, name): Student.count+=1 def show(self): print Student.count #静态方法1 @staticmethod def haha(): print Student.count #静态方法2 @classmethod def ss(cls): print cls.count 阅读全文
posted @ 2013-01-20 22:15 程序猿刚子 阅读(404) 评论(0) 推荐(0) 编辑