So I have this URL scheme:
(r'^test/(?P<name>\d+开发者_如何转开发)/', 'test'),
def test(request, name):
html = "it worked"
return HttpResponse(html)
however, when I go to the following URL, I get a 404 error:
http://127.0.0.1:8000/test/words/
What am I doing wrong?
You probably meant to use \w
instead, e.g.:
(r'^test/(?P<name>\w+)/', 'test'),
\d
matches only digits; \w
matches any alphanumeric character.
Python Regular Expression HOWTO by A.M. Kuchling.
精彩评论