代码:
class Counter(object):
__secount=0
publicfs=0
def getcount(self):
self.__secount+=1
self.publicfs+=1
print(self.__secount)
d=Counter()
d.getcount()
print d.publicfs
print(d._Counter__secount)#访问私有变量
2024-01-03 18:10:04
代码:
class Counter(object):
__secount=0
publicfs=0
def getcount(self):
self.__secount+=1
self.publicfs+=1
print(self.__secount)
d=Counter()
d.getcount()
print d.publicfs
print(d._Counter__secount)#访问私有变量