package identity, rather than a folder.
- In pycharm in new, and Python Package Directory has two options.
- Directory and create separate package, found that the former is just an empty directory, which contains a __init__.py file.
- This is the package __init__.py identify the role, he told the python, this is not an ordinary directory but a python module package (module package).
- Usually empty file, but it must exist.
Import simplified block
For example: test.py would like to quote mysql.py and redis.py, because is not under the same folder, and not directly applicable.
__init__.py code is as follows:
The module in the current packet are introduced into __init__.py file, or blur introduced introducing both methods can be accurately.
# Vague import, import all # (representative of the current folder) from . Import * # precise import from . Import MySQL, Redis
test.py code is as follows:
import tools
Run about test.py, successful references mysql.py and redis.py