【问题标题】:What is the difference between request.POST.get and request.POSTrequest.POST.get 和 request.POST 有什么区别
【发布时间】:2022-11-23 02:47:58
【问题描述】:

通常我使用 POST 或 GET 请求,除了 GET.get 分页,但我不明白这个概念只有两种可能性 POST 或 GET 。

例如,即使有相同的效果,我也不明白两者之间的区别 request.GET.get('page') and request.GET["page"] request.POST['rate'] and request.POST.get('rate')

【问题讨论】:

    标签: django forms


    【解决方案1】:

    request.POST 是一个类似dict 的对象。

    对于dicts及其派生词,d[x]等同于通过键x索引到dict,而d.get(x, default)是等同于索引的方法,除了它返回一个默认值而不是抛出一个@ 987654328@。如果未设置默认值,d.get() 将返回 None。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-06
      • 1970-01-01
      • 2010-10-02
      • 2011-12-12
      • 2010-09-16
      • 2012-03-14
      • 2012-02-06
      相关资源
      最近更新 更多