标签:访问 一个 参数表 外部 内部类 不同 -- 共享 object
2.8 类的属性
2.9 类的方法
3.0 类的内置方法
class People(object):
color = "yellow"
__age = 30
def think(self):
self.color = ‘black‘
print("I am a %s" %self.color)
print("I am a thinker")
print(self.__age)
ren = People()
ren.color = ‘黑人‘
print(ren.color)
ren.think()
print(ren.__dict__)
print(‘#‘ * 30)
print(People.color)
print(‘#‘ * 30)
print(People.__dict__)
class People(object):
color = "yellow"
__age = 30
def think(self):
self.color = ‘black‘
print("I am a %s" %self.color)
print("I am a thinker")
print(self.__age)
def __talk(self):
print("I am talking with Tom")
@classmethod
def test(self):
print("this is class method")
@staticmethod
def test1():
print("this is static method")
jack = People()
People.test()
People.test1()
标签:访问 一个 参数表 外部 内部类 不同 -- 共享 object
原文地址:http://blog.51cto.com/13542406/2059599