#!python3 #encoding:utf-8 class TestClass: def __init__(self): pass self._private_field = 100 self.__private_field = 101 def _private_method(self): print("this is private method 1.") def __private_method(self): print("this is private method 2.") if __name__ == "__main__": c = TestClass() print(str(c._private_field)) # print(str(c.__private_field)) c._private_method() # c.__private_method() print(str(c._TestClass__private_field)) c._TestClass__private_method() c = TestClass()