Introduction to Python object-oriented and the difference between ordinary methods, class methods, and static methods

1. Features are attributes, actions are methods

Insert picture description here

2. Use classes to create objects

Insert picture description here

3. Class attributes and object attributes

Insert picture description here
Insert picture description here

4. The def in the class is the method

Insert picture description here
Insert picture description here

phone1 now when calling call, it passes its own address into call, that is, it passes me in, self is what I mean, whoever calls call, self is whoever is, pass in as a parameter, self It is dynamic and constantly changing.

Insert picture description here
How to solve the above shadow?

One of the magic methods

Insert picture description here

Insert picture description here

5. Class method:

Insert picture description here
Insert picture description here

6. Static method:

Insert picture description here

7, the difference between the three

Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_44994799/article/details/110206659