>>> dict = { 1 : 2, 'a' : 'b', 'hello' : 'world' } >>> dict.values() ['b', 2, 'world'] >>> dict.keys() ['a', 1, 'hello'] >>> dict.items() [('a', 'b'), (1, 2), ('hello', 'world')] returns a list of tuple >>>
QueryDicts 与标准字典的区别:
和标准字典的 items() 方法一样, 不同的是它和 __getitem()__ 一样,返回最后一个值:
>>> q = QueryDict('a=1&a=2&a=3') >>> q.items() [('a', '3')]