本文整理汇总了Python中paste.util.multidict.MultiDict.pop方法的典型用法代码示例。如果您正苦于以下问题:Python MultiDict.pop方法的具体用法?Python MultiDict.pop怎么用?Python MultiDict.pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类paste.util.multidict.MultiDict
的用法示例。
在下文中一共展示了MultiDict.pop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dict
# 需要导入模块: from paste.util.multidict import MultiDict [as 别名]
# 或者: from paste.util.multidict.MultiDict import pop [as 别名]
def test_dict():
d = MultiDict({'a': 1})
assert list(d.items()) == [('a', 1)]
d['b'] = 2
d['c'] = 3
assert list(d.items()) == [('a', 1), ('b', 2), ('c', 3)]
d['b'] = 4
assert list(d.items()) == [('a', 1), ('c', 3), ('b', 4)]
d.add('b', 5)
assert_raises(KeyError, d.getone, "b")
assert d.getall('b') == [4, 5]
assert list(d.items()) == [('a', 1), ('c', 3), ('b', 4), ('b', 5)]
del d['b']
assert list(d.items()) == [('a', 1), ('c', 3)]
assert d.pop('xxx', 5) == 5
assert d.getone('a') == 1
assert d.popitem() == ('c', 3)
assert list(d.items()) == [('a', 1)]
item = []
assert d.setdefault('z', item) is item
assert list(d.items()) == [('a', 1), ('z', item)]
assert d.setdefault('y', 6) == 6
assert d.mixed() == {'a': 1, 'y': 6, 'z': item}
assert d.dict_of_lists() == {'a': [1], 'y': [6], 'z': [item]}
assert 'a' in d
dcopy = d.copy()
assert dcopy is not d
assert dcopy == d
d['x'] = 'x test'
assert dcopy != d
d[(1, None)] = (None, 1)
assert list(d.items()) == [('a', 1), ('z', []), ('y', 6), ('x', 'x test'),
((1, None), (None, 1))]