【发布时间】:2015-07-12 11:34:07
【问题描述】:
全部:
在 Django 中,我使用这些词来获取 dict(q_a),但是在第一个 dict() 之后,第二个是 null,python 是如何工作的?
if request.method == "POST":
q_a = request.POST.iteritems()
print "type of q_a is %s" % q_a
print "first dict(q_a) : %s " % dict(q_a)
print "second dict(q_a): %s " % dict(q_a)
这里是打印输出:
type of q_a is <generator object _iteritems at 0x10c97ac30>
first dict(q_a) : {u'csrfmiddlewaretoken': u'KQA7K6MCwZWFsXO59pAOYOMyD92O9tYq', u'\u5b66\u9662': u'ss', u'\u59d3\u540d': u'ww', u'\u624b\u673a\u53f7\u7801': u''}
second dict(q_a): {}
【问题讨论】:
-
这是一个奇怪的空iterator案例。
-
help(dict.iteritems).
标签: python django dictionary