Skip to main content
 首页 » 编程设计

python之为 MVC 模式组织我的 python 项目,

2025年05月04日7hnrainll

Python 对我来说是新手,我在组织文件代码时遇到了问题。

我想做这样的事情:

./ 
 /views 
        index.html  // Django files 
 
 /controlers 
        main.py 
 
 /models 
        Greeting.py  // I take the same classe exemple of Google App Engine Website 
 /libs 
        xxx.py //some Lib and tools classes   
 /static 
        /js 
        /css 
        /images 

真正的问题是文件树在 python 环境中是正确的吗?

请您参考如下方法:

是的,您的结构有效,或者如果您发现我的示例有用,下面是我如何组织一个较小的应用引擎应用程序:

. 
├── app.yaml 
├── conf.py 
├── main.py 
├── model.py 
├── static 
│   ├── 1.gif 
│   ├── 2.gif 
│   ├── 3.gif 
│   ├── 4.gif 
│   ├── anim.gif 
│   ├── main.css 
│   ├── main.js 
└── templates 
    ├── base.html 
    ├── error.html 
    ├── info.html 
    ├── upload.html 
    ├── user.html 
    └── welcome.html