This article focuses on Python's approach to import modules at different levels of the catalog, and it is often useful to use a third-party module package when you need a friend to write a program using Python. This package can be installed via the Python setup install and imported via the import XXX or from xxx import yyy. However, if it is a self-written dependency package, and do not want to install to the corresponding Python directory, you can put in this directory for import to call, in order to clarify the relationship between the program, for example, we will put this package in the Lib directory and then call. This article summarizes the common module invocation methods. One, the same level directory of the program structure is as follows:--src |--mod1.py |--test1.py If import module test1.py in the program MOD1, then directly use import MOD1 or from mod1 import *;
1. Analyzing Python's approach to import modules at different levels of the catalog
Introduction: This article mainly introduces python in different levels of directory Import module method, the need for friends can refer to the following
2. Python uses tips
Introduction: 1. Import module often uses import declarations in Python to use objects defined in other modules (that is, other. py files). (1), using __name__ write test statement below is a simple library program testlib.py. When running testlib.py directly, __name__ is "__main__". If it is import, ...
3. Python Module Search concept Introduction and Module installation Method introduction
Introduction: This article mainly introduces the Python module search concept Introduction and the module installation method Introduction, this article explained in detail the Import module operation principle, the search path process as well as the module installs the many methods, needs the friend can refer to the next
4. Import module with old Ziko python
Introduction: This article mainly explains the basic import module method, first from the definition of the module, and then tell how to write their own module, very simple and practical, the need for friends can refer to the next
"Related question and answer recommendation":
Python-what is the meaning of parentheses () when importing modules using from XXX import (xxx, xxx, xxx)?
How do I import a dependent module that I wrote when Python-spark submit?
python-pycharm2.7.3 cannot import module
pycharm2.7.3 cannot import module