推荐学习书目
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 · May 10, 2015 · 2913 views
    This topic created in 4025 days ago, the information mentioned may be changed or developed.
    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 replies    2015-05-11 16:11:39 +08:00
    RIcter
        1
    RIcter  
       May 10, 2015
    _(:3」∠)_
    是那个 index 没错..
    redhatping
        2
    redhatping  
    OP
       May 10, 2015
    楼上,但是我改成class homepage: 一样可以运行啊?
    RIcter
        3
    RIcter  
       May 10, 2015
    @redhatping 你 ctrl-c 重新运行。
    czheo
        4
    czheo  
       May 11, 2015
    @livid 你说发帖自动把每一行的空格都去掉了是一个好的feature么?
    Livid
        5
    Livid  
    MOD
    PRO
       May 11, 2015
    @czheo 你现在再看一下帖子。

    V2EX 是有 Markdown 功能的。

    https://www.v2ex.com/new
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2756 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 00:03 · PVG 08:03 · LAX 17:03 · JFK 20:03
    ♥ Do have faith in what you're doing.