开发者

A Simple Python Regular Expression Problem in Google App Engine

I am learning Google App Engine in Python.

Here is my problem:

I want the visitor to visit my website in the following format,

hxxp://www.example.com/wiki/A_Example_Title

The variable after /wiki/ only contains al开发者_运维问答phabets and underscore.

application = webapp.WSGIApplication([
    ('/wiki/??????', wikipage),

What should the ???? part be?

Thanks a lot!


try one of these:

Your spec said 'alphabets and underscore' -- this one gets that and numbers as well:

r'/wiki/(\w+)'

...if you really don't want numbers in there, use this:

r'/wiki/([A-Za-z_]+)'

The characters captured by that regex will be passed as a parmeter to your wikipage get() handler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜