标签:
一、私有:
只能类自己本身成员内部可以访问
class Foo: def __init__(self,name): self.__name = name #私有的 def f1(self): print(self.__name) obj = Foo(‘alex‘) #print(obj.__name) #不能这样访问 obj.f1()
out:
alex
class Foo: __cc = "123" def __init__(self,name): self.__name = name def f1(self): print(self.__name) @staticmethod def f3(): print(Foo.__cc) Foo.f3()
out:
123
二、公有:
标签:
原文地址:http://www.cnblogs.com/pangguoping/p/5617914.html