热线电话:13121318867

登录
2019-06-24 阅读量: 750
访问可见性问题
class Test:

def __init__(self, foo):
self.__foo = foo

def __bar(self):
print(self.__foo)
print('__bar')


def main():
test = Test('hello')
# AttributeError: 'Test' object has no attribute '__bar'
test.__bar()
# AttributeError: 'Test' object has no attribute '__foo'
print(test.__foo)


if __name__ == "__main__":
main()
0.0000
4
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子