<<Python 基础教程>>
为了让方法或者特性变为私有(从外部无法访问),只要在它们的名字前面加上双下划线:
class Secretive:
def __inaccessible(self):
print 'Best you can't see me...'
def accessible(self):
print 'The secret message is:'
self.__inaccessible()
<<Python 基础教程>>
为了让方法或者特性变为私有(从外部无法访问),只要在它们的名字前面加上双下划线:
class Secretive:
def __inaccessible(self):
print 'Best you can't see me...'
def accessible(self):
print 'The secret message is:'
self.__inaccessible()