Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of python Public members and Private members

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you the python public and private members of the sample analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!

1. Public members can be used publicly, that is, they can access the internal or external programs of the class.

By default, the default member variables of a class in Python are exposed.

2. Private members cannot directly access the outside of the class, generally access and operate inside the class, or call the public members of the object on the outside of the class.

This is an important embodiment of the class encapsulation feature.

Example

Class Point: X = 10 _ y = 20 z = 30 def get_x (self): return self.x def get_y (self): return self.__y def _ get_z (self): return self.z is all the contents of the article "sample Analysis of python Public and Private members". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report