Python also has object-oriented thinking, then everything is Object
A class is defined in Python:
Class Student:
count = 0
Books = []
def __init__ (Self,name,grade)
Self.name=name
Self.grade=grade
def ex (self):
If self.grade== ' 1 ':
print ' AAA '
Else
print ' CCC '
In the defined class, self is equivalent to this in Java, which is equivalent to the instance itself
Access control Through "_" and "__" in the Python class
Data Properties
In the student class above, "Count" "Books" "Name" and "age" are all referred to as data properties of the class, but they are divided into class data properties and instance data properties
"_": A variable of type protected that begins with a single underscore, that is, it can only be accessed by itself and the subclass, and also represents a weak internal variable, such as when using "from modulenmae import *", an object that begins with an underscore is not introduced.
"__": a double underline represents a variable of a private type. You can only allow access to the class itself, not even subclasses, which add a single underscore and a class name to the runtime property name.
Inherited:
Supports both single-inheritance and multi-inheritance in Python
Python class and Singleton mode