Python与QueryDirets directory items(), keys(), values()

来源:互联网 发布:企业域名实名认证 编辑:程序博客网 时间:2024/06/07 07:24
>>> 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')]


原创粉丝点击