类是私有属性
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) #调用age
ren = People()
print(ren.color)
ren.think()
print ("-"*66)
print(ren._People__age)
输出:
yellow
i am a black
i am a thinker
30
------------------------------------------------------------------
30
写入自己的博客中才能记得长久