V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
redhatping
V2EX  ›  Python

python 中的 web 框架下的一些命名问题?

  •  
  •   redhatping · 2015-05-10 15:10:46 +08:00 · 2266 次点击
    这是一个创建于 3281 天前的主题,其中的信息可能已经有所发展或是发生改变。
    import web
    
    urls = ('/','index')
    
    app = web.application(urls,globals())
    
    class index:
        def GET(self):
            greeting = 'hello word'
            return greeting
    
    if __name__ == "__main__":
        app.run()
    

    urls = ('/','index') 中index到底是class index的index吗?
    可如果我换成这样,照样运行啊?

    class homepage:
        def GET(self):
            greeting = 'hello word'
            return greeting
    
    5 条回复    2015-05-11 16:11:39 +08:00
    RIcter
        1
    RIcter  
       2015-05-10 15:31:48 +08:00
    _(:3」∠)_
    是那个 index 没错..
    redhatping
        2
    redhatping  
    OP
       2015-05-10 16:15:59 +08:00
    楼上,但是我改成class homepage: 一样可以运行啊?
    RIcter
        3
    RIcter  
       2015-05-10 16:43:50 +08:00
    @redhatping 你 ctrl-c 重新运行。
    czheo
        4
    czheo  
       2015-05-11 10:21:48 +08:00
    @livid 你说发帖自动把每一行的空格都去掉了是一个好的feature么?
    Livid
        5
    Livid  
    MOD
       2015-05-11 16:11:39 +08:00
    @czheo 你现在再看一下帖子。

    V2EX 是有 Markdown 功能的。

    https://www.v2ex.com/new
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2156 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:52 · PVG 23:52 · LAX 08:52 · JFK 11:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.