​Full analysis of Python module knowledge

Module definition
A Python module (Module) is a file that ends in .py and contains data, functions, classes, etc. Usually it is a script that can be executed directly, or a bunch of code similar to library functions.

What are the benefits of using modules

Classification of modules

Several ways to import modules

The principle of import is to search for the corresponding python file or package in the specified range, execute it, and get the method in it.

In Python, the keyword import is used to import a certain module. The commonly used import methods are as follows.

Search order of imported modules

  1. Search the current directory.
  2. Not in the current directory, Python searches every directory under the shell variable PYTHONPATH (the module search path is stored in the sys.path variable of the system module. The variable contains the current directory, PYTHONPATH and the default directory determined by the installation process).
  3. If none is found, Python will check the default path. Under UNIX, the default path is generally /usr/local/lib/python/.

**The general import rules are as follows: **

In the same package:

In different packages:

**Several modules commonly used in Python are as follows: **

Recommended Posts

​Full analysis of Python module knowledge
Basic knowledge of Python (1)
Prettytable module of python
Python analysis of wav files
Analysis of JS of Python crawler
Analysis of Python Sandbox Escape
Analysis of Python object-oriented programming
matplotlib of python drawing module
Analysis of usage examples of Python yield
Python3 module
Analysis of Python conditional control statements
Python requests module cookie instance analysis
Basic analysis of Python turtle library implementation
Detailed analysis of Python garbage collection mechanism
Analysis of glob in python standard library
Summary of common operations of Python time module
Method of installing django module in python
Analysis of common methods of Python multi-process programming
Knowledge points of shell execution in python
7 features of Python3.9
Python data analysis
Python knowledge points
Python Lesson 37-Module
Method analysis of Python calling C language program
Detailed explanation of the usage of Python decimal module
Analysis of common methods of Python operation Jira library
Python implementation of AI automatic matting example analysis
Python3 built-in module usage
Python3 supplementary knowledge points
Python advanced knowledge points
Python crawls the full set of skins of the king pesticide
Basics of Python syntax
Python3 external module use
Basic syntax of Python
09. Common modules of Python3
Consolidate the foundation of Python (4)
Consolidate the foundation of Python(7)
In-depth understanding of python list (LIST)
Subscripts of tuples in Python
Python basic knowledge question bank
Consolidate the foundation of Python(6)
Python3 crawler data cleaning analysis
2020--Python grammar common knowledge points
python king of glory wallpaper
Consolidate the foundation of Python(5)
Python implementation of gomoku program
Some new features of Python 3.10
Deep understanding of Python multithreading
Python version of OpenCV installation
Python Data Science: Related Analysis
9 feature engineering techniques of Python
Python method of parameter passing
Python Faker data forgery module
Consolidate the foundation of Python (3)
Collection of Python Common Modules
Python crawls a full set of skins for the glory of the king
Python crawler advanced essential | Decryption logic analysis of an index analysis platform