码迷,mamicode.com
首页 > 编程语言 > 详细

python web简易框架体验

时间:2020-02-04 17:13:04      阅读:87      评论:0      收藏:0      [点我收藏+]

标签:ret   attr   python   pen   image   das   import   arm   class   

————————

  ————data #保存class类及类中的对象

  ————int #执行程序

————————————

技术图片
#@Time:2020/2/4 16:48
#@Author :jok
#@file :data.py
#@software:PyCharm
class web:
    def home(self):
        return "首页"
    def list(self):
        return "列表"
    def a_404(self):
        return "404"
    def page(self):
        return "page"
data.py
技术图片
#@Time:2020/2/4 16:48
#@Author :jok
#@file :int.py
#@software:PyCharm
import data
while True:
    int = input("请输入要访问的页面")
    web = getattr(data,"web")
    if hasattr(web,int):
        func = getattr(web(),int)
        print(func())
    else:
        print(getattr(web(),"a_404")())
int.py

效果截图

技术图片

 

python web简易框架体验

标签:ret   attr   python   pen   image   das   import   arm   class   

原文地址:https://www.cnblogs.com/bdua/p/12260080.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!