python

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

九三
249
2021-02-18 14:53:29
栏目: 编程语言
Python开发者服务器,限时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元/月。点击查看>>

相关推荐:如何通过C++成员函数指针访问私有成员

0
看了该问题的人还看了