如何访问python的私有成员函数

824
2021/2/18 14:53:29
栏目: 编程语言
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

如何访问python的私有成员函数

访问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元/月。点击查看>>

推荐阅读: python怎么查找数组中元素位置