下面看代码.
#coding=utf-8
class A:
def __init__(self):
self.__foo = 'foo'
self._bar = 'bar'
a = A()
print a.__dict__
print a._bar
print a.__foo #这句会报错
下面汇总下python的下划线约定,
更多约定详情到http://www.python.org/dev/peps/pep-0008/#descriptive-naming-styles
什么是Name_mangling以及python的下划线约定
原文地址:http://blog.csdn.net/handsomekang/article/details/40303207