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

2015-05-10 15:10:46 +08:00
 redhatping
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
2294 次点击
所在节点    Python
5 条回复
RIcter
2015-05-10 15:31:48 +08:00
_(:3」∠)_
是那个 index 没错..
redhatping
2015-05-10 16:15:59 +08:00
楼上,但是我改成class homepage: 一样可以运行啊?
RIcter
2015-05-10 16:43:50 +08:00
@redhatping 你 ctrl-c 重新运行。
czheo
2015-05-11 10:21:48 +08:00
@livid 你说发帖自动把每一行的空格都去掉了是一个好的feature么?
Livid
2015-05-11 16:11:39 +08:00
@czheo 你现在再看一下帖子。

V2EX 是有 Markdown 功能的。

https://www.v2ex.com/new

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/189934

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX