【发布时间】:2014-01-31 22:31:00
【问题描述】:
我需要匹配 url 中的 url 编码空格,即 %20。
我的网址会是这样的
http://domain/something/hello%20world
这是我的 url 配置和视图
url(r'^regtest/(\w+[%20]?\w+)', views.regView)
查看:
def regView(request, x, y=None):
print x, 'and', y
return HttpResponse('+OK')
这是我从 url 获得点击时的日志
http://127.0.0.1:8000/regtest/hello%20world
hello and None
[13/Jan/2014 02:12:31] "GET /regtest/hello%20world HTTP/1.1" 200 3
【问题讨论】:
标签: regex django django-urls