class People(object):
def __init__(self):
self.__age = 20
people = People()
print(people.__age)
Traceback (most recent call last):
File "C:/Users/flydack/Desktop/day02/private.py", line 8, in <module>
print(people.__age)
AttributeError: 'People' object has no attribute '__age'
for i in dir(people):
print(i)
_People__age
__class__
__delattr__
__dict__
__dir__
__doc__
__eq__
__format__
__ge__
__getattribute__
__gt__
__hash__
__init__
__init_subclass__
__le__
__lt__
__module__
__ne__
__new__
__reduce__
__reduce_ex__
__repr__
__setattr__
__sizeof__
__str__
__subclasshook__
__weakref__
print(people._People__age)
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |