current position：Home>Python learning notes - the fifth bullet * class & object oriented
Python learning notes - the fifth bullet * class & object oriented
2022-02-01 07:03:26 【goonwalk】
「 This is my participation 11 The fourth of the yuegengwen challenge 16 God , Check out the activity details ：2021 One last more challenge 」.
object-oriented programming ——object oriented programming, abbreviation OOP, It's a design idea .OOP Take the object as the basic unit of the program , An object contains data and functions that manipulate data .Python Classes in provide all the basic functions of object-oriented programs ： Class inheritance mechanism allows multiple base classes , Derived classes can override any method in the base class , Method can call a method with the same name in the base class . Objects can contain any number and type of data . class ： Represents a description of a collection of types , attribute ：
Some features of the class itself , Such as （ One of the ） name , Attributes such as height and weight . The specific value of the attribute will vary according to each person .
Method ： The behavior that a class can achieve , How to eat , Walking, etc .
1. The definition of a class
class classname[( Parent class name )]：# The parent class name is optional , If a parent class is defined , Then the subclass inherits the properties and methods of the parent class [ Member functions and member variables ]
2. Class object
Class objects support two operations ： Property references and instantiations .
Property references use and Python All attributes in reference to the same standard and method ：obj.name.
After the class object is created , All names in the class namespace are valid property names .
Many classes tend to create objects with initial states . Therefore, the class may define a class named init（） Special method （ Construction method ）,init（） Method can have parameters , Parameters through init（） Passed to the instantiation operation of the class ：
3. Class method
Inside the class , Use def Keyword can define a method for a class , Different from general function definition , Class method must contain parameters self, And it's the first parameter ：
author[goonwalk],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Django paging (II)
- Concurrent. For Python concurrent programming Futures or multiprocessing?
- Programmers over the age of 25 can't know a few Chinese herbal medicines. Python crawler lessons 9-9
- Python crawler from introduction to pit full series of tutorials (detailed tutorial + various practical combat)
- The second bullet of class in Python
- Python object oriented programming 03: class inheritance and its derived terms
- How IOS developers learn Python Programming 13 - function 4
- Python crawler from introduction to mastery (VI) form and crawler login
- Python crawler from entry to mastery (V) challenges of dynamic web pages
- Deeply understand pandas to read excel, TXT, CSV files and other commands
guess what you like
Daily python, Chapter 18, class
"I just want to collect some plain photos in Python for machine learning," he said. "I believe you a ghost!"
Python implements filtering emoticons in text
When winter comes, python chooses a coat with temperament for mom! Otherwise, there's really no way to start!
Python crawler - get fund change information
Highlight actor using Python VTK
Python crawler actual combat: crawling southern weekend news articles
leetcode 406. Queue Reconstruction by Height（python）
leetcode 1043. Partition Array for Maximum Sum （python）
- Python * * packaging and unpacking details
- Python realizes weather query function
- Python from 0 to 1 (day 12) - Python data application 2 (STR function)
- Python from 0 to 1 (day 13) - Python data application 3
- Numpy common operations of Python data analysis series Chapter 8
- How to implement mockserver [Python version]
- Van * Python! Write an article and publish the script on multiple platforms
- Python data analysis - file reading
- Python data De duplication and missing value processing
- Python office automation - play with browser
- Python series tutorial 127 -- Reference vs copy
- Control flow in Python: break and continue
- Teach you how to extract tables in PDF with Python
- leetcode 889. Construct Binary Tree from Preorder and Postorder Traversal（python）
- leetcode 1338. Reduce Array Size to The Half（python）
- Object oriented and exception handling in Python
- How to configure load balancing for Django service
- How to embed Python in go
- Python Matplotlib drawing graphics
- Python object-oriented programming 05: concluding summary of classes and objects
- Python from 0 to 1 (day 14) - Python conditional judgment 1
- Several very interesting modules in Python
- How IOS developers learn Python Programming 15 - object oriented programming 1
- Daily python, Chapter 20, exception handling
- Understand the basis of Python collaboration in a few minutes
- [centos7] how to install and use Python under Linux
- leetcode 1130. Minimum Cost Tree From Leaf Values（python）
- leetcode 1433. Check If a String Can Break Another String（python）
- Python Matplotlib drawing 3D graphics
- Talk about deep and shallow copying in Python
- Python crawler series - network requests
- Python thread 01 understanding thread
- Analysis of earthquake distribution in the past 10 years with Python~
- You need to master these before learning Python crawlers
- After the old friend (R & D post) was laid off, I wanted to join the snack bar. I collected some data in Python. It's more or less a intention
- Python uses redis
- Python crawler - ETF fund acquisition
- Detailed tutorial on Python operation Tencent object storage (COS)
- [Python] comparison of list, tuple, array and bidirectional queue methods
- Go Python 3 usage and pit Prevention Guide