Python-调用 Private 变量

Python 调用 Private 变量。

1
2
3
4
5
6
7
8
9
10
11
12
class P:
def __init__(self, name, alias):
self.name = name # public
self.__alias = alias # private

def who(self):
print('name : ', self.name)
print('alias : ', self.__alias)

from p import P
x = P(name='Alex', alias='amen')
x._P__alias