當前位置: 首頁>>代碼示例>>Python>>正文


Python DictMixin.items方法代碼示例

本文整理匯總了Python中UserDict.DictMixin.items方法的典型用法代碼示例。如果您正苦於以下問題:Python DictMixin.items方法的具體用法?Python DictMixin.items怎麽用?Python DictMixin.items使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserDict.DictMixin的用法示例。


在下文中一共展示了DictMixin.items方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: write

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def write(self, f):
        """ Write namespace as INI file.

        :param f: File object or path to file.

        """
        if isinstance(f, str):
            f = io.open(f, 'w', encoding='utf-8')

        if not hasattr(f, 'read'):
            raise AttributeError("Wrong type of file: {0}".format(type(f)))

        NS_LOGGER.info('Write to `{0}`'.format(f.name))
        for section in self.sections.keys():
            f.write('[{0}]\n'.format(section))
            for k, v in self[section].items():
                f.write('{0:15}= {1}\n'.format(k, v))
            f.write('\n')
        f.close() 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:21,代碼來源:inirama.py

示例2: __reduce__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __reduce__(self):
        items = [[k, self[k]] for k in self]
        tmp = self.__map, self.__end
        del self.__map, self.__end
        inst_dict = vars(self).copy()
        self.__map, self.__end = tmp
        if inst_dict:
            return (self.__class__, (items,), inst_dict)
        return self.__class__, (items,) 
開發者ID:ME-ICA,項目名稱:me-ica,代碼行數:11,代碼來源:_ordered_dict.py

示例3: __repr__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __repr__(self):
        if not self:
            return '%s()' % (self.__class__.__name__,)
        return '%s(%r)' % (self.__class__.__name__, self.items()) 
開發者ID:ME-ICA,項目名稱:me-ica,代碼行數:6,代碼來源:_ordered_dict.py

示例4: __eq__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            return len(self)==len(other) and self.items() == other.items()
        return dict.__eq__(self, other) 
開發者ID:ME-ICA,項目名稱:me-ica,代碼行數:6,代碼來源:_ordered_dict.py

示例5: __eq__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            if len(self) != len(other):
                return False
            for p, q in  zip(self.items(), other.items()):
                if p != q:
                    return False
            return True
        return dict.__eq__(self, other) 
開發者ID:remg427,項目名稱:misp42splunk,代碼行數:11,代碼來源:ordereddict.py

示例6: iteritems

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def iteritems(self, raw=False):
        """ Iterate self items. """

        for key in self:
            yield key, self.__getitem__(key, raw=raw) 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:7,代碼來源:inirama.py

示例7: __init__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __init__(self, **default_items):
        self.sections = OrderedDict()
        for k, v in default_items.items():
            self[self.default_section][k] = v 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:6,代碼來源:inirama.py

示例8: parse

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def parse(self, source, update=True, **params):
        """ Parse INI source as string.

        :param source: Source of INI
        :param update: Replace already defined items

        """
        scanner = INIScanner(source)
        scanner.scan()

        section = self.default_section
        name = None

        for token in scanner.tokens:
            if token[0] == 'KEY_VALUE':
                name, value = re.split('[=:]', token[1], 1)
                name, value = name.strip(), value.strip()
                if not update and name in self[section]:
                    continue
                self[section][name] = value

            elif token[0] == 'SECTION':
                section = token[1].strip('[]')

            elif token[0] == 'CONTINUATION':
                if not name:
                    raise SyntaxError(
                        "SyntaxError[@char {0}: {1}]".format(
                            token[2], "Bad continuation."))
                self[section][name] += '\n' + token[1].strip() 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:32,代碼來源:inirama.py

示例9: __eq__

# 需要導入模塊: from UserDict import DictMixin [as 別名]
# 或者: from UserDict.DictMixin import items [as 別名]
def __eq__(self, other):
        if isinstance(other, OrderedDict):
            return len(self)==len(other) and \
                   all(p==q for p, q in  zip(self.items(), other.items()))
        return dict.__eq__(self, other) 
開發者ID:gkudos,項目名稱:qgis-cartodb,代碼行數:7,代碼來源:ordered_dict.py


注:本文中的UserDict.DictMixin.items方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。