Example Analysis of python Public members and Private members
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!