Head first python cainiao Study Notes (Chapter 6), python Study Notes
1. Python provides a dictionary that allows you to effectively organize data and associate the data with the name to achieve quick search, rather than associate the data with numbers.
A dictionary is a built-in data structure that allows you to associate data with keys rather than numbers. In this way, the data in the memory is consistent with the actual data structure .???
2. Package the Code and its data into a class: Python allows you to create and define an object-oriented class, which can be used to associate the Code with the data processed by the Code. Code and the data it processes can be defined as a class. Once a class is defined, you can use it to instantiate a data object. It inherits the features of the class.
Where:
The Code is a class method.
Data is a class attribute
The instantiated data object is an instance.
3. Use class to define a class. The method is as follows:
All methods defined in the class must use self as its first function:
ImportantPythonExecuted code .!!!!!!
4. Extended built-in classes to add custom attributes
How to inherit python's built-in list class.
First, derive the built-in list class to create a custom list
Summary:
1. Use the dict () factory function or {} to create an empty dictionary.
2.
3. Define the _ init _ () method to initialize the object instance. Each method in the class must provide self as the first parameter. Each attribute in the class must have self before it, so that the data is connected to the instance.