# 路由 命名分组
urlpatterns = [
    ......
    # URL地址上捕获的参数会按照 关键字传参 方式传递给试图函数
    url(r'^blogs/(?P<year>[0-9]{4})/(?P<month>\d{2})/$', views.blogs),
]

# views.py
def blogs(request, *args, **kwargs):
    print(year, type(year))
    print(month, type(month))
    return HttpResponse('Blogs')

# 结果
[28/Jul/2021 08:18:46] "GET /blogs/2022/03/ HTTP/1.1" 200 5
2022 <class 'str'>
03 <class 'str'>

 

相关文章:

  • 2022-03-02
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2022-01-13
  • 2022-12-23
  • 2021-08-22
  • 2022-12-23
猜你喜欢
  • 2021-12-11
  • 2022-02-17
  • 2021-08-30
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案