[root@blackfox zhouyuyao]# cat c8.py
#!/usr/bin/python
#coding:utf8
class MyClass(object):
name = 'Test'
def __init__(self):
self.func1()
self.__func2()
self.classFun()
self.staticFun()
def func1(self):
print self.name
print "我是公有方法"
def __func2(self):
print self.name
print "我是私有方法"
@classmethod
def classFun(self):
print self.name
print "我是类方法"
@staticmethod
def staticFun():
print MyClass.name
print "我是静态方法"
mc = MyClass()
#mc.func1()
#mc.__func2()
#MyClass.classFun()
#MyClass.staticFun()
本文转自 归来仍少年 51CTO博客,原文链接:http://blog.51cto.com/shaoniana/1886360