访问python私有成员函数的方法
class Plane():
# 私有属性
__air_sister = "20个"
# 公有绑定方法
def fly(self):
print("飞机会飞")
# 公有普通方法
def fly2():
print("飞机会飞2")
# 私有的绑定方法
def __oil_info(self):
print("飞机百公里油耗是100升")
# 私有的普通方法
def __oil_info2():
print("飞机百公里油耗是100升")
# 公有的绑定方法
def pub_info(self):
print(self.__air_sister)
self.__oil_info()
# 公有的普通方法
def pub_info2():
print(Plane.__air_sister)
Plane.__oil_info2()
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:如何通过C++成员函数指针访问私有成员