-3
我对这种行为感到困惑。代码只是打印请求的类型。第一种方法有效,但第二种方法返回空字符串。该类的类型是django.corehandlers.wsgi.WSGIRequest。Django - 请求类型
(编辑澄清)
def someview(request):
html+="<p>type of the request each char "
for i in range(47):
html+= (str(type(request))[i])
html+="</p>"
html+="<p>type of the request each char "
for i in range(47):
html+= repr(str(type(request))[i])
html+="</p>"
return HttpResponse(html)
结果如下。第二个字符串是空的。
type of the request each char '<''c''l''a''s''s'' '"'"'d''j''a''n''g''o''.''c''o''r''e''.''h''a''n''d''l''e''r''s''.''w''s''g''i''.''W''S''G''I''R''e''q''u''e''s''t'"'"'>'
type of the request:
你想在这里做什么?类型(请求)应该给你''左右。如果你拿这个len():18个字符。那么你如何得到47?你传递给函数的是什么?你的目标是什么? –
你想拥有“?”吗?符号由'str(type(request))'评估结果替换? –