项目结构 ######## 最广泛的 python 项目结构:: └─myproject │ .gitignore │ LICENSE │ readme.md │ requirements.txt │ setup.py │ ├─myproject │ main.py │ util.py │ __init__.py │ └─test test_main.py 命令行式项目的结构:: sample/ ├── .gitignore ├── LICENSE ├── README.rst ├── requirements.txt ├── sample.py ├── setup.py └── test_sample.py 带子应用的项目结构:: └─myproject │ .gitignore │ LICENSE │ readme.md │ requirements.txt │ setup.py │ ├─myproject │ │ main.py │ │ util.py │ │ __init__.py │ │ │ ├─app_sample │ │ │ sample.py │ │ │ __init__.py │ │ │ │ │ └─__pycache__ │ │ sample.cpython-39.pyc │ │ __init__.cpython-39.pyc │ │ │ └─__pycache__ │ main.cpython-39.pyc │ __init__.cpython-39.pyc │ └─test test_main.py 适用于 setuptools 构建工具的项目结构:: project_root_directory ├── pyproject.toml # 项目配置文件,或者使用 setup.cfg, setup.py ├── ... # 如 readme.rst, license等 └── src/ └── mypkg/ ├── __init__.py ├── ... ├── module.py |---- data | |----- data1.json | |---- data2.xml ├── subpkg1/ │ ├── __init__.py │ ├── ... │ └── module1.py └── subpkg2/ ├── __init__.py ├── ... └── module2.py Flask 项目结构:: flaskr-tutorial/ ├── flaskr/ │ ├── ___init__.py │ ├── db.py │ ├── schema.sql │ ├── auth.py │ ├── blog.py │ ├── templates/ │ │ ├── base.html │ │ ├── auth/ │ │ │ ├── login.html │ │ │ └── register.html │ │ └── blog/ │ │ ├── create.html │ │ ├── index.html │ │ └── update.html │ └── static/ │ └── style.css ├── tests/ │ ├── data.sql │ ├── test_auth.py │ ├── test_blog.py │ ├── test_conf.py │ ├── test_db.py │ └── test_factory.py ├── venv/ ├── .gitignore ├── setup.py └── MANIFEST.in 机器学习项目结构:: sample/ ├── data/ │ ├── external/ │ ├── interim/ │ ├── processed/ │ └── raw/ ├── models/ ├── notebooks/ ├── sample/ │ ├── data/ │ ├── features/ │ └── model/ ├── tests/ ├── .gitignore ├── LICENSE ├── README.rst ├── requirements.txt └── setup.py 参考 ==== * https://blog.csdn.net/captain5339/article/details/128017400