码迷,mamicode.com
首页 > 编程语言 > 详细

python之collections之有序字典(OrderedDict)

时间:2016-12-15 11:58:24      阅读:218      评论:0      收藏:0      [点我收藏+]

标签:清除   war   src   err   restore   efault   false   添加   技术   

一、定义
OrderedDict是对字典的补充,它记住了字典元素的添加顺序。
eg:

技术分享

技术分享

二、OrderedDict相关方法
def clear(self): # real signature unknown; restored from __doc__
"""
    od.clear() -> None. Remove all items from od.
    清除有序字典中的元素
  """
pass
eg:

技术分享

技术分享

 


def copy(self): # real signature unknown; restored from __doc__
"""
    od.copy() -> a shallow copy of od
    有序字典的浅拷贝
  """
pass



def items(self, *args, **kwargs): # real signature unknown
取有序字典的元素
   pass

def keys(self, *args, **kwargs): # real signature unknown
  取key
pass

def move_to_end(self, *args, **kwargs): # real signature unknown
"""
Move an existing element to the end (or beginning if last==False).

Raises KeyError if the element does not exist.
When last=True, acts like a fast version of self[key]=self.pop(key).
  把指定的元素放到尾部
"""
pass
eg:

技术分享

技术分享

 


def pop(self, k, d=None): # real signature unknown; restored from __doc__
"""
od.pop(k[,d]) -> v, remove specified key and return the corresponding
value. If key is not found, d is returned if given, otherwise KeyError
is raised.
  弹出指定的key
"""
pass
eg:

技术分享

技术分享

 



def popitem(self): # real signature unknown; restored from __doc__
"""
od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
  从尾部开始弹出
"""
pass
eg:

技术分享

技术分享

 


def setdefault(self, k, d=None): # real signature unknown; restored from __doc__
"""
    od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od
    设置默认值
  """
pass

def update(self, *args, **kwargs): # real signature unknown
pass

def values(self, *args, **kwargs): # real signature unknown
pass

python之collections之有序字典(OrderedDict)

标签:清除   war   src   err   restore   efault   false   添加   技术   

原文地址:http://www.cnblogs.com/baotouzhangce/p/6182366.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!