python项目结构设计_Python工程的文档结构

Project/

|-- bin/

| |-- project

|

|-- project/

| |-- test/

| | |-- __init__.py

| | |-- test_main.py

| |

| |-- __init__.py

| |-- main.py

|

|-- setup.py

|-- README

img_eeb8b0fe349365909feb95633525e082.png

其实更好的方法,可能是直接去GitHub上参考高赞项目的结构,比如PySpider(https://github.com/binux/pyspider)的文档结构:

PySpider

.

├── Dockerfile

├── LICENSE

├── MANIFEST.in

├── README.md

├── data

├── docs

│ ├── About-Projects.md

│ ├── About-Tasks.md

│ ├── Architecture.md

│ ├── Command-Line.md

│ ├── Deployment-demo.pyspider.org.md

│ ├── Deployment.md

│ ├── Frequently-Asked-Questions.md

│ ├── Quickstart.md

│ ├── Running-pyspider-with-Docker.md

│ ├── Script-Environment.md

│ ├── Working-with-Results.md

│ ├── apis

│ │ ├── @catch_status_code_error.md

│ │ ├── @every.md

│ │ ├── Response.md

│ │ ├── index.md

│ │ ├── self.crawl.md

│ │ └── self.send_message.md

│ ├── conf.py

│ ├── imgs

│ │ ├── creating_a_project.png

│ │ ├── css_selector_helper.png

│ │ ├── demo.png

│ │ ├── developer-tools-network-filter.png

│ │ ├── developer-tools-network.png

│ │ ├── index_page.png

│ │ ├── inspect_element.png

│ │ ├── pyspider-arch.png

│ │ ├── request-headers.png

│ │ ├── run_one_step.png

│ │ ├── search-for-request.png

│ │ ├── tutorial_imdb_front.png

│ │ └── twitch.png

│ ├── index.md

│ └── tutorial

│ ├── AJAX-and-more-HTTP.md

│ ├── HTML-and-CSS-Selector.md

│ ├── Render-with-PhantomJS.md

│ └── index.md

├── mkdocs.yml

├── pyspider

│ ├── __init__.py

│ ├── database

│ │ ├── __init__.py

│ │ ├── base

│ │ │ ├── __init__.py

│ │ │ ├── projectdb.py

│ │ │ ├── resultdb.py

│ │ │ └── taskdb.py

│ │ ├── basedb.py

│ │ ├── elasticsearch

│ │ │ ├── __init__.py

│ │ │ ├── projectdb.py

│ │ │ ├── resultdb.py

│ │ │ └── taskdb.py

│ │ ├── local

│ │ │ ├── __init__.py

│ │ │ └── projectdb.py

│ │ ├── mongodb

│ │ │ ├── __init__.py

│ │ │ ├── mongodbbase.py

│ │ │ ├── projectdb.py

│ │ │ ├── resultdb.py

│ │ │ └── taskdb.py

│ │ ├── mysql

│ │ │ ├── __init__.py

│ │ │ ├── mysqlbase.py

│ │ │ ├── projectdb.py

│ │ │ ├── resultdb.py

│ │ │ └── taskdb.py

│ │ ├── redis

│ │ │ ├── __init__.py

│ │ │ └── taskdb.py

│ │ ├── sqlalchemy

│ │ │ ├── __init__.py

│ │ │ ├── projectdb.py

│ │ │ ├── resultdb.py

│ │ │ ├── sqlalchemybase.py

│ │ │ └── taskdb.py

│ │ └── sqlite

│ │ ├── __init__.py

│ │ ├── projectdb.py

│ │ ├── resultdb.py

│ │ ├── sqlitebase.py

│ │ └── taskdb.py

│ ├── fetcher

│ │ ├── __init__.py

│ │ ├── cookie_utils.py

│ │ ├── phantomjs_fetcher.js

│ │ ├── splash_fetcher.lua

│ │ └── tornado_fetcher.py

│ ├── libs

│ │ ├── ListIO.py

│ │ ├── __init__.py

│ │ ├── base_handler.py

│ │ ├── bench.py

│ │ ├── counter.py

│ │ ├── dataurl.py

│ │ ├── log.py

│ │ ├── multiprocessing_queue.py

│ │ ├── pprint.py

│ │ ├── response.py

│ │ ├── result_dump.py

│ │ ├── sample_handler.py

│ │ ├── url.py

│ │ ├── utils.py

│ │ └── wsgi_xmlrpc.py

│ ├── logging.conf

│ ├── message_queue

│ │ ├── __init__.py

│ │ ├── beanstalk.py

│ │ ├── kombu_queue.py

│ │ ├── rabbitmq.py

│ │ └── redis_queue.py

│ ├── processor

│ │ ├── __init__.py

│ │ ├── processor.py

│ │ └── project_module.py

│ ├── result

│ │ ├── __init__.py

│ │ └── result_worker.py

│ ├── run.py

│ ├── scheduler

│ │ ├── __init__.py

│ │ ├── scheduler.py

│ │ ├── task_queue.py

│ │ └── token_bucket.py

│ └── webui

│ ├── __init__.py

│ ├── app.py

│ ├── bench_test.py

│ ├── debug.py

│ ├── index.py

│ ├── login.py

│ ├── result.py

│ ├── static

│ │ ├── css_selector_helper.min.js

│ │ ├── debug.min.css

│ │ ├── debug.min.js

│ │ ├── index.min.css

│ │ ├── index.min.js

│ │ ├── package.json

│ │ ├── result.min.css

│ │ ├── result.min.js

│ │ ├── src

│ │ │ ├── css_selector_helper.js

│ │ │ ├── debug.js

│ │ │ ├── debug.less

│ │ │ ├── index.js

│ │ │ ├── index.less

│ │ │ ├── result.less

│ │ │ ├── splitter.js

│ │ │ ├── task.less

│ │ │ ├── tasks.less

│ │ │ └── variable.less

│ │ ├── task.min.css

│ │ ├── task.min.js

│ │ ├── tasks.min.css

│ │ ├── tasks.min.js

│ │ └── webpack.config.js

│ ├── task.py

│ ├── templates

│ │ ├── debug.html

│ │ ├── index.html

│ │ ├── result.html

│ │ ├── task.html

│ │ └── tasks.html

│ └── webdav.py

├── requirements.txt

├── run.py

├── setup.py

├── tests

│ ├── __init__.py

│ ├── data_fetcher_processor_handler.py

│ ├── data_handler.py

│ ├── data_sample_handler.py

│ ├── data_test_webpage.py

│ ├── test_base_handler.py

│ ├── test_bench.py

│ ├── test_counter.py

│ ├── test_database.py

│ ├── test_fetcher.py

│ ├── test_fetcher_processor.py

│ ├── test_message_queue.py

│ ├── test_processor.py

│ ├── test_response.py

│ ├── test_result_dump.py

│ ├── test_result_worker.py

│ ├── test_run.py

│ ├── test_scheduler.py

│ ├── test_task_queue.py

│ ├── test_utils.py

│ ├── test_webdav.py

│ ├── test_webui.py

│ └── test_xmlrpc.py

├── tools

│ └── migrate.py

└── tox.ini

27 directories, 177 files

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
对于Python项目结构,没有一个固定的标准,但是有一些常见的组织方式可以参考。下面是一个比较常见的Python项目结构: ``` project/ │ ├── src/ │ ├── __init__.py │ ├── module1.py │ ├── module2.py │ └── ... │ ├── tests/ │ ├── __init__.py │ ├── test_module1.py │ ├── test_module2.py │ └── ... │ ├── docs/ │ ├── conf.py │ ├── index.rst │ ├── ... │ └── _static/ │ ├── setup.py ├── requirements.txt └── README.md ``` 其中,`src/` 目录存放项目的源代码,`tests/` 目录存放项目的测试代码,`docs/` 目录存放项目文档,`setup.py` 是项目的安装脚本,`requirements.txt` 是项目的依赖列表,`README.md` 是项目的说明文件。 在 `src/` 目录下,可以根据项目的功能将代码分为不同的模块,每个模块放在一个单独的 `.py` 文件中,同时需要在 `__init__.py` 文件中导入这些模块以便其他代码可以使用。 在 `tests/` 目录下,可以编写测试代码,一般使用 Python 的测试框架(如 unittest、pytest 等)进行测试。 在 `docs/` 目录下,可以编写项目文档,一般使用 reStructuredText 或 Markdown 格式,使用 Sphinx 工具生成 HTML 或 PDF 格式的文档。 最后,在项目根目录下,需要编写 `setup.py` 文件以便其他人可以安装和使用你的项目。在 `requirements.txt` 文件中列出项目的依赖,以便其他人可以通过 `pip` 安装这些依赖。 以上是一个常见的Python项目结构,但实际上可以根据项目的具体情况进行调整和修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值