python web简易框架体验
Posted 三道_python
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python web简易框架体验相关的知识,希望对你有一定的参考价值。
————————
————data #保存class类及类中的对象
————int #执行程序
————————————
![](https://image.cha138.com/20210602/daf01992b0874e04877cfae98d269d1a.jpg)
#@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"
![](https://image.cha138.com/20210602/daf01992b0874e04877cfae98d269d1a.jpg)
#@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")())
效果截图
以上是关于python web简易框架体验的主要内容,如果未能解决你的问题,请参考以下文章
Python实现简易HTTP服务器与MINI WEB框架(利用WSGI实现服务器与框架解耦)