Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Django中将beginURL与REGEX匹配_Python_Regex_Django - Fatal编程技术网

Python 如何在Django中将beginURL与REGEX匹配

Python 如何在Django中将beginURL与REGEX匹配,python,regex,django,Python,Regex,Django,我对API URL使用以下语法: http://myhost/myapiname/X-Y-Z/web-service-name/ 在Django URL.py中,它如下所示: url(r'api_s/2-0-0/get_client_profile/$', GetClientProfile.as_detail(), name='get_client_profile'), 现在,我想将所有1-0-0 URL(不推荐使用的Web服务)重定向到特定视图。 我尝试了类似于url(r'api\u t/

我对API URL使用以下语法:

http://myhost/myapiname/X-Y-Z/web-service-name/
在Django URL.py中,它如下所示:

url(r'api_s/2-0-0/get_client_profile/$', GetClientProfile.as_detail(), name='get_client_profile'),
现在,我想将所有1-0-0 URL(不推荐使用的Web服务)重定向到特定视图。
我尝试了类似于
url(r'api\u t/1-0-0*$,已弃用。as\u list(),name='弃用')
的方法,但无法捕获。我不习惯正则表达式,所以我这里遗漏了一些东西。谢谢。

*
前面加一个点:

url(r'api_t/1-0-0.*$', Deprecated.as_list(), name='deprecated')
星号
*
表示“重复上一个符号zere或更多次”。点
表示“任何字符”。因此,
*
将匹配任何字符串