Python-100-Days/Day01-15/code/Day08/access.py

19 lines
266 B
Python
Raw Normal View History

2018-04-27 00:00:22 +08:00
class Test:
2019-05-03 21:17:36 +08:00
def __init__(self, foo):
self.__foo = foo
2018-04-27 00:00:22 +08:00
2019-05-03 21:17:36 +08:00
def __bar(self):
print(self.__foo)
print('__bar')
2018-04-27 00:00:22 +08:00
def main():
2019-05-03 21:17:36 +08:00
test = Test('hello')
test._Test__bar()
print(test._Test__foo)
2018-04-27 00:00:22 +08:00
if __name__ == "__main__":
2019-05-03 21:17:36 +08:00
main()